###解決したいこと
Railsのバージョンを上げました。そしたら、Herokuへデプロイする際、JSON::ParserError: 416 のエラーが出るようになってしまいました。
色々と検索したりしておりますが、JSON::ParserError: 416 の情報がネット上に少なく、未だ一人で解決できずにいます。
ぜひお力添えをいただければ幸いです。
version
1Rails 5.2.6 2ruby 2.5.0p0 3Bundler version 2.2.17
error
1remote: -----> Preparing app for Rails asset pipeline 2remote: Running: rake assets:precompile 3remote: Yarn executable was not detected in the system. 4remote: Download Yarn at https://yarnpkg.com/en/docs/install 5remote: rake aborted! 6remote: JSON::ParserError: 416: unexpected token at '{"code":"!function(t,e){\"object\"==typeof module&&\"object\"==typeof module.exports?module.exports=t.document?e(t,!0):function(t){if(!t.document)throw new Error(\"jQuery requires a window with a document\");return e(t)}:e(t)}(\"undefined\"!=typeof window?window:this,function(E,t){function a(t){var e=!!t&&\"length\"in 7. 8.(文字数の関係上省略) 9. 10. 11{}}e&&this.empty().append(t)},null,t,arguments.length)},replaceWith:function(){var n=[];return A(this,arguments,function(t){var e=this.parentNode;ft.inArray(this,n)<0&&(ft.cleanDa' 12remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/execjs-2.8.0/lib/execjs/external_runtime.rb:68:in `extract_result' 13remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/execjs-2.8.0/lib/execjs/external_runtime.rb:39:in `exec' 14remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/execjs-2.8.0/lib/execjs/external_runtime.rb:21:in `eval' 15remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/execjs-2.8.0/lib/execjs/external_runtime.rb:46:in `call' 16remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/uglifier-4.2.0/lib/uglifier.rb:221:in `run_uglifyjs' 17remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/uglifier-4.2.0/lib/uglifier.rb:166:in `compile' 18remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:53:in `call' 19remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:28:in `call' 20remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor' 21remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors' 22remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `reverse_each' 23remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors' 24remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded' 25remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load' 26remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache' 27remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load' 28remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize' 29remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load' 30remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset' 31remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:73:in `find_all_linked_assets' 32remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:142:in `block in find' 33remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths' 34remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:228:in `block in stat_tree' 35remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:212:in `block in stat_directory' 36remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `each' 37remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `stat_directory' 38remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:227:in `stat_tree' 39remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `each' 40remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `block in logical_paths' 41remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `each' 42remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `logical_paths' 43remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:140:in `find' 44remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:186:in `compile' 45remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/task.rb:67:in `block (3 levels) in define' 46remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/rake/sprocketstask.rb:147:in `with_logger' 47remote: /tmp/build_f6b23ca5/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/task.rb:66:in `block (2 levels) in define' 48remote: Tasks: TOP => assets:precompile 49remote: (See full trace by running task with --trace) 50remote: 51remote: ! 52remote: ! Precompiling assets failed. 53remote: ! 54remote: ! Push rejected, failed to compile Ruby app.
###やってること
①こちらのサイトで、unexpected token at以降に吐き出している部分をVALIDATEしました。
http://jsonlint.com
おそらく、"code":の :が違う!と言われているような気がしますが、application.js内にcodeという単語はありません。また、schemaにもございません。
把握するにあたり、必要な情報がございましたら追記しますのでお教えください。
②delvelopmentではエラーは出ませんが、
RAILS_ENV=development bin/rails assets:precompile
productionで確認してみると、
RAILS_ENV=production bin/rails assets:precompile
[1/4] ???? Resolving packages... success Nothing to install. success Saved lockfile. ✨ Done in 0.10s. rails aborted! JSON::ParserError: 416: unexpected token at '{"code":"(function............
が発生します。
railsやbundlerなどのバージョンを上げた為に、発生しましたので、もし近日で解決できなければバージョンをダングレードしたりして対応したいと思ってます。。
STDERR.puts uriをbase.rbの指定の箇所へ追加して、RAILS_ENV=production bin/rails assets:precompileで出力
#abortedの最初の部分 file:///Users/XOXO/saas/app/assets/images/favicon.png?type=image/png file:///Users/XOXO/saas/app/assets/images/personalfile-top.jpg?type=image/jpeg file:///Users/XOXO/saas/app/assets/javascripts/application.js?type=application/javascript rails aborted! JSON::ParserError: 416: unexpected token at '{"code":"(function..
#unexpected token at '{の最後の部分 "input\"===e&&!!t.checked||\"option\"===e&&!!t.selected},selected:function(t){return t.parentNode&&t.parentNode.selectedIndex,!0===t.selected},empty:function(t){for(t=t.firstChild;t;t=t.nextSibling)if(t.nodeType<6)return!1;return!0},parent:function(t){return!S.pseudos.empty(t)},header:function(t){return mt.test(t.nodeName)},input:function(t){return ht.test(t.nodeName)},button:function(t){var e=t.nodeName.toLowerCase();return\"input\"===e&&\"button\"===t.type||\"button\"===e},text:function(t){var e;return\"input\"===t.nodeName.toLowerCase()&&\"text\"===t.type&&(null==(e=t.getAttribute(\"type\"))||\"text\"===e.toLowerCase())},first:a(function(){return[0]}),last:a(function(t,e){return[e-1]}),eq:a(function(t,e,n){return[n<0?n+e:n]}),even:a(function(t,e){for(var n=0;n<e;n+=2)t.push(n);return t}),odd:a(function(t,e){for(var n=1;n<e;n+=2)t.push(n);return t}),lt:a(function(t,e,n){for(var r=n<0?n+e:n;0<=--r;)t.push(r);return t}),gt:a(function(t,e,n){for(var r=n<0?n+e:n;++r<e;)t.push(r);return t})}}).pseudos.nth=S.pseudos.eq,{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})S.pseudos[h]=r(h);for(h in{submit:!0,reset:!0})S.pseudos[h]=o(h);return s.prototype=S.filters=S.pseudos,S.setFilters=new s,k=w.tokenize=function(t,e){var n,r,i,o,a,s,u,l=U[t+\" \"];if(l)return e?0'
appplication.jsの内容を全て削除し、以下のようにしましたが、デプロイはできませんでした
//= require rails-ujs //= require activestorage //= require jquery //= require jquery_ujs //= require turbolinks //= require_tree .
しかし、STDERR.puts uriを残したまま、デプロイを行いましたところ、以下のような内容が出力されました
bundle lock --add-platform x86_64-linuxの実行結果
MacBook-Air:saas XOXO$ bundle lock --add-platform x86_64-linux Fetching gem metadata from https://rubygems.org/............ Resolving dependencies..... Writing lockfile to /Users/XOXO/saas/Gemfile.lock
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/05/12 05:06
2021/05/12 05:12
2021/05/12 06:01
2021/05/12 06:06
2021/05/12 06:48
2021/05/12 08:08
2021/05/12 08:30
2021/05/12 10:07 編集
2021/05/12 09:17
2021/05/12 09:55
2021/05/12 10:07 編集
2021/05/12 10:20
2021/05/12 10:39
2021/05/12 11:28
2021/05/12 11:35