gpt4 book ai didi

ruby-on-rails-4 - 耙子中止! JSON::GeneratorError:rake Assets 后源序列非法/格式错误的 utf-8:预编译

转载 作者:行者123 更新时间:2023-12-04 07:07:45 24 4
gpt4 key购买 nike

我完成了一个网站的构建并想将其部署到 Digital Ocean VPN。安装 Capistrano 和乘客。在初始部署期间,我收到一个错误,显然与预编译 Assets 有关,因此我在本地的 Rails 生产环境中尝试了“rake assets:precompile --trace RAILS_ENV=production”,并且该过程因以下消息而中止:“JSON: :GeneratorError: 源序列非法/格式错误 utf-8"
谁能帮我解决这个问题,我似乎无法解决这个问题。

> rake aborted! JSON::GeneratorError: source sequence is
> illegal/malformed utf-8
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/json-1.8.3/lib/json/common.rb:223:in
> `generate'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/json-1.8.3/lib/json/common.rb:223:in
> `generate'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/execjs-2.5.2/lib/execjs/external_runtime.rb:46:in
> `call'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/uglifier-2.7.1/lib/uglifier.rb:212:in
> `run_uglifyjs'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/uglifier-2.7.1/lib/uglifier.rb:179:in
> `compile'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/uglifier_compressor.rb:52:in `call'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/uglifier_compressor.rb:28:in `call'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:75:in
> `call_processor'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:57:in
> `block in call_processors'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:56:in
> `reverse_each'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:56:in
> `call_processors'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/loader.rb:86:in
> `load_asset_by_uri'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/loader.rb:45:in
> `block in load'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/loader.rb:155:in
> `fetch_asset_from_dependency_cache'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/loader.rb:38:in
> `load'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:20:in
> `block in initialize'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:47:in
> `yield'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:47:in
> `load'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/base.rb:63:in
> `find_asset'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/base.rb:70:in
> `find_all_linked_assets'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/manifest.rb:138:in
> `block in find'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:114:in
> `block (2 levels) in logical_paths'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:223:in
> `block in stat_tree'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:207:in
> `block in stat_directory'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:204:in
> `each'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:204:in
> `stat_directory'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:222:in
> `stat_tree'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:105:in
> `each'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:105:in
> `block in logical_paths'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:104:in
> `each'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:104:in
> `logical_paths'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/manifest.rb:136:in
> `find'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/sprockets/manifest.rb:162:in
> `compile'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-rails-2.3.1/lib/sprockets/rails/task.rb:70:in
> `block (3 levels) in define'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-3.2.0/lib/rake/sprocketstask.rb:147:in
> `with_logger'
> /Users/franco/.rvm/gems/ruby-2.2.2/gems/sprockets-rails-2.3.1/lib/sprockets/rails/task.rb:69:in
> `block (2 levels) in define'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in
> `call'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in
> `block in execute'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in
> `each'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in
> `execute'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:179:in
> `block in invoke_with_call_chain'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/monitor.rb:211:in
> `mon_synchronize'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:172:in
> `invoke_with_call_chain'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/task.rb:165:in
> `invoke'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:150:in
> `invoke_task'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in
> `block (2 levels) in top_level'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in
> `each'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in
> `block in top_level'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:115:in
> `run_with_threads'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:100:in
> `top_level'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:78:in
> `block in run'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in
> `standard_exception_handling'
> /Users/franco/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:75:in
> `run' /Users/franco/.rvm/rubies/ruby-2.2.2/bin/rake:33:in `<main>'
> Tasks: TOP => assets:precompile

最佳答案

我遇到了完全相同的错误消息。有了这个告示,我用谷歌搜索“检查文件是否有效 utf-8”并找到 isutf8(1): check whether files are valid UTF-8 - Linux man page .所以我安装了 isutf8 然后从我的 linux 机器上的 Rails 根运行以下命令

isutf8 `find app`

虽然输出中有很多噪音,但它告诉我 app/assets/javascripts/filterbar.js: line 1, char 1, byte offset 41: invalid UTF-8 code .所以我打开了那个文件。中提琴!我看到了一些乱码。一旦我删除了这些字符,我的 rake assets:precompile成功了。当然,您的实际有罪文件可能会有所不同。您还可以使用其他实用程序来检查 utf-8,例如 this stackoverflow question on utf-8 , 当然。

关于ruby-on-rails-4 - 耙子中止! JSON::GeneratorError:rake Assets 后源序列非法/格式错误的 utf-8:预编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31372478/

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