gpt4 book ai didi

ruby-on-rails - 为什么我在 UTF-8 中得到无效的字节序列

转载 作者:行者123 更新时间:2023-12-04 08:54:31 31 4
gpt4 key购买 nike

为什么会出现此错误?

invalid byte sequence in UTF-8

用于加载图像:
= image_tag 'features_home/show1.png'

编辑

我注意到这个问题是在我做完之后才出现的 bundle update , 任何图像都会发生错误.. 我将尝试在此处添加详细信息:

堆栈跟踪:
  Rendered home/home.html.haml within layouts/application (229.9ms)
Completed 500 Internal Server Error in 1047ms
invalid byte sequence in UTF-8 excluded from capture: DSN not set

ActionView::Template::Error (invalid byte sequence in UTF-8):
81: / Carousel items
82: .carousel-inner
83: .active.item
84: = image_tag 'features_home/show1.png'
85: -#.carousel-caption
86: -# %h4
87: -# %p
app/views/home/home.html.haml:84:in `block in _app_views_home_home_html_haml__623651309533727079_70331260863620'
app/views/home/home.html.haml:33:in `_app_views_home_home_html_haml__623651309533727079_70331260863620'
lib/rack/seoredirect.rb:20:in `call'


Rendered /Users/Apple/.rvm/gems/ruby-2.2.2@myapp/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_source.erb (115.6ms)
Rendered /Users/Apple/.rvm/gems/ruby-2.2.2@myapp/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (23.1ms)
Rendered /Users/Apple/.rvm/gems/ruby-2.2.2@myapp/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.7ms)
Rendered /Users/Apple/.rvm/gems/ruby-2.2.2@myapp/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (237.9ms)

Gemfile.lock 前后 bundle update : https://gist.github.com/hopewise/35c2a98b13ac646b65770feb2f3c7ec8

完整跟踪:
https://gist.github.com/hopewise/551169518a5938647dc767d3de393cd4

我不知道是哪个 gem 导致了这个问题..

最佳答案

这似乎是 less-rails 中的一个错误Haml 用于解析 image_tag 路径的 gem指示。

调用时image_tag , less-rails最终尝试扫描文件所依赖的 Assets ,但可能会无意中使用非文本文件。这会导致您遇到错误。

fix exists在项目中正确验证路径的(有些过时的)分支上。我们可以拉进来进行测试:

gem 'less-rails', github: 'metaskills/less-rails', branch: 'depends_only_on_less_files' 

请查看 this ticket了解更多详细信息。正如那里所建议的,您可能需要验证代码是否使用了适当的图像路径。

关于ruby-on-rails - 为什么我在 UTF-8 中得到无效的字节序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41646921/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com