vagrantのローカル環境からbitbucketにpushする前にいつも、以下のコマンドでアセットをプリコンパイルしています。
RAILS_ENV=production bundle exec rake assets:precompile assets:clean
しかし、最近、ちょいちょい以下のエラーになります。
ruby
1git:(master) ✗ RAILS_ENV=production bundle exec rake assets:precompile assets:clean 2rake aborted! 3ExecJS::RuntimeError: 4(execjs):1 5/home/vagrant/.rbenv/versions/2.3.1/bin/bundle:22:in `load' 6/home/vagrant/.rbenv/versions/2.3.1/bin/bundle:22:in `<main>' 7Tasks: TOP => assets:precompile 8(See full trace by running task with --trace)
今の所、vagrantを再起動すると問題なくプリコンパイル出来るようになるので、適時それで対応しているのですが、これは何が要因なのでしょうか?
一応gemfileとnode.jsの情報を記載致します。
node.jsのバージョン
ruby
1node -v 2v0.10.48
gemfile
ruby
1source 'https://rubygems.org' 2 3 4# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 5 gem 'rails', '~> 5.0.0' 6# Use mysql as the database for Active Record 7 gem 'mysql2','>=0.3.18','< 0.5' 8# Use Puma as the app server 9 gem 'puma', '~> 3.0' 10# Us SCSS for stylesheets 11 gem 'sass-rails', '~> 5.0' 12# Use Uglifier as compressor for JavaScript assets 13 gem 'uglifier', '>= 1.3.0' 14# Use CoffeeScript for .coffee assets and views 15 gem 'coffee-rails', '~> 4.2.0' 16 17# Use jquery as the JavaScript library 18 gem 'jquery-rails' 19# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 20 gem 'turbolinks', '~> 5' 21# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 22 gem 'jbuilder', '~> 2.5' 23# bundle exec rake doc:rails generates the API under doc/api. 24#gem 'sdoc', '~> 0.4.0', group: :doc 25 26# Use ActiveModel has_secure_password 27# gem 'bcrypt', '~> 3.1.7' 28 29# Use Unicorn as the app server 30# gem 'unicorn' 31 32gem 'slim-rails' 33 34# Use Capistrano for deployment 35group :development do 36 gem 'capistrano-rails' 37 gem 'capistrano-rbenv' 38 gem 'capistrano3-puma' 39 40 # Access an IRB console on exception pages or by using <%= console %> in views 41 gem 'web-console', '~> 2.0' 42 gem 'listen', '~> 3.0.5' 43 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 44 gem 'spring' 45 gem 'spring-watcher-listen', '~> 2.0.0' 46end 47 48group :development, :test do 49 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 50 gem 'byebug', platform: :mri 51end 52 53group :production do 54 # See https://github.com/rails/execjs#readme for more supported runtimes 55 # gem 'therubyracer', platforms: :ruby 56end 57 58# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 59gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 60 61# https://github.com/kossnocorp/jquery.turbolinks 62gem 'jquery-turbolinks' 63 64# https://github.com/svenfuchs/rails-i18n 65gem 'rails-i18n', '~> 5.0.0' 66 67# https://github.com/plataformatec/devise 68gem 'devise' 69 70# gem 'omniauth' 71# gem 'omniauth-twitter' 72 73# https://github.com/tigrish/devise-i18n 74gem 'devise-i18n' 75 76# https://github.com/carrierwaveuploader/carrierwave 77gem 'carrierwave' 78 79# https://github.com/kuroda/mail-iso-2022-jp 80gem 'mail-iso-2022-jp' 81 82# https://github.com/amatsuda/kaminari 83gem 'kaminari' 84 85gem 'fog' 86 87# https://github.com/minimagick/minimagick 88gem 'mini_magick' 89 90gem 'rmagick', require: 'rmagick' 91 92# https://github.com/alfa-jpn/kakurenbo-puti 93gem 'kakurenbo-puti' 94 95# https://github.com/leppert/remotipart 96gem 'remotipart', '~> 1.3', '>= 1.3.1' 97 98# ----------SEO------------- 99# https://github.com/kpumuk/meta-tags 100gem 'meta-tags', require: 'meta_tags' 101 102# https://github.com/ankane/searchkick 103# https://rubyplus.com/articles/4031-Autocomplete-using-Typeahead-and-Searchkick-in-Rails-5 104# gem 'searchkick' 105 106# https://github.com/k0kubun/rack-user_agent 107gem 'rack-user_agent' 108 109gem 'font-awesome-rails' 110gem 'jquery-ui-rails' 111 112# https://github.com/mwlang/gentelella-rails 113gem 'gentelella-rails' 114 115gem 'redis' 116gem 'redis-rails' 117 118# https://github.com/lassebunk/gretel 119gem "gretel" 120 121gem 'chart-js-rails'
therubyracerは入れていませんが、node.jsを入れているので問題ないと思っています。
このエラーに遭遇するまでnode.jsさえ入れてなかったのですが、問題なくプリコンパイルできていました。
このエラーが出たので、node.jsを入れて、発生頻度が100%ではなくなったという状況です。
(もしかしたら、node.js入れなくても最初からvagrant再起動すれば問題なかったのかも知れません。)
他に気になる点としては、これもたまになのですが、viewで以下のようなエラーが発生します。
ruby
1ActionView::Template::Error (can't add a new key into hash during iteration): 2 4: meta charset="UTF-8" 3 5: title サービス名 4 6: = csrf_meta_tags 5 7: = stylesheet_link_tag 'managements', 'data-turbolinks-track': 'reload', media: 'all' 6 8: = javascript_include_tag 'managements', 'data-turbolinks-track': 'reload' 7 9: meta name="robots" content="noindex,nofollow" 8 10:
なんとなく、どちらの問題も根源は同じのような気がするのですが、分かりません。
再現性が100%ではないのも気持ちが悪いです。
このような事象について、原因となるものが何か検討がつく方はいらっしゃいますでしょうか?
あなたの回答
tips
プレビュー