sstephenson / execjs

Run JavaScript code from Ruby
MIT License
1.16k stars 46 forks source link

ExecJS::RuntimeError: (execjs):1 during assets:precompile #201

Closed fahmiardhianto closed 8 years ago

fahmiardhianto commented 8 years ago

Hi, I'm getting this error when trying to deploy my Rails app using mina. I have node v4.4.4 installed and have successfully deployed my app in its previous version, but now I don't know what the problem is. I've tried this solution to edit the runtimes file but no luck. Tried restart the server and app, still got this error. There's suggestion to reinstall node but I don't think that will solve the problem.

rake aborted! ExecJS::RuntimeError: (execjs):1 /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs/external_runtime.rb:219:in exec_runtime' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs/external_runtime.rb:39:inexec' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs/external_runtime.rb:21:in eval' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs/external_runtime.rb:46:incall' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/babel-transpiler-0.7.0/lib/babel/transpiler.rb:28:in transform' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-es6-0.9.0/lib/sprockets/es6.rb:64:intransform' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-es6-0.9.0/lib/sprockets/es6.rb:58:in block in call' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/cache.rb:85:infetch' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-es6-0.9.0/lib/sprockets/es6.rb:57:in call' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-es6-0.9.0/lib/sprockets/es6.rb:34:incall' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:75:in call_processor' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:57:inblock in call_processors' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:56:in reverse_each' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:56:incall_processors' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/loader.rb:134:in load_from_unloaded' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/loader.rb:60:inblock in load' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/loader.rb:317:in fetch_asset_from_dependency_cache' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/loader.rb:44:inload' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:20:in block in initialize' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:47:inload' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/bundle.rb:23:in block in call' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/utils.rb:183:indfs' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/bundle.rb:24:in call' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:75:incall_processor' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:57:in block in call_processors' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:56:inreverse_each' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/processor_utils.rb:56:in call_processors' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/loader.rb:134:inload_from_unloaded' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/loader.rb:60:in block in load' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/loader.rb:317:infetch_asset_from_dependency_cache' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/loader.rb:44:in load' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:20:inblock in initialize' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/cached_environment.rb:47:in load' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/base.rb:66:infind_asset' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/base.rb:73:in find_all_linked_assets' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/manifest.rb:142:inblock in find' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/legacy.rb:114:in block (2 levels) in logical_paths' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/path_utils.rb:223:inblock in stat_tree' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/path_utils.rb:207:in block in stat_directory' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/path_utils.rb:204:ineach' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/path_utils.rb:204:in stat_directory' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/path_utils.rb:222:instat_tree' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/legacy.rb:105:in each' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/legacy.rb:105:inblock in logical_paths' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/legacy.rb:104:in each' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/legacy.rb:104:inlogical_paths' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/manifest.rb:140:in find' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/sprockets/manifest.rb:185:incompile' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-rails-3.0.4/lib/sprockets/rails/task.rb:68:in block (3 levels) in define' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-3.6.0/lib/rake/sprocketstask.rb:147:inwith_logger' /home/deploy/handl/tmp/build-1464647429288/vendor/bundle/ruby/2.3.0/gems/sprockets-rails-3.0.4/lib/sprockets/rails/task.rb:67:in block (2 levels) in define' /home/deploy/.rbenv/versions/2.3.1/bin/bundle:23:inload' /home/deploy/.rbenv/versions/2.3.1/bin/bundle:23:in `

' Tasks: TOP => assets:precompile (See full trace by running task with --trace) ! ERROR: Deploy failed.

fahmiardhianto commented 8 years ago

It turns out resetting the server solve the problem.

frgooall commented 8 years ago

I still having this issues, even when resetting the server, got it to work before, but now no luck! I love the speed of Mina and want to continue to use it for rails deployment.

Here is my deploy file -

require 'mina/bundler' require 'mina/rails' require 'mina/git' require 'mina/rbenv' # for rbenv support. (http://rbenv.org)

set :domain, '162.243.5.47' set :deploy_to, '/var/www/buildsimply' set :repository, 'git@github.com:frgooall/build_simply.git' set :branch, 'master'

set :shared_paths, ['config/database.yml', 'config/secrets.yml', 'log', 'public/uploads']

set :user, 'deploy' # Username in the server to SSH to. set :ssh_options, '-A' task :environment do invoke :'rbenv:load' end

task :setup => :environment do queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"] queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]

queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"] queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/config"]

queue! %[touch "#{deploy_to}/#{shared_path}/config/database.yml"] queue! %[touch "#{deploy_to}/#{shared_path}/config/secrets.yml"] queue %[echo "-----> Be sure to edit '#{deploy_to}/#{shared_path}/config/database.yml' and 'secrets.yml'."]

if repository repo_host = repository.split(%r{@|://}).last.split(%r{:|\/}).first repo_port = /:([0-9]+)/.match(repository) && /:([0-9]+)/.match(repository)[1] || '22'

queue %[
  if ! ssh-keygen -H  -F #{repo_host} &>/dev/null; then
    ssh-keyscan -t rsa -p #{repo_port} -H #{repo_host} >> ~/.ssh/known_hosts
  fi
]

end end

desc "Deploys the current version to the server." task :deploy => :environment do to :before_hook do

Put things to run locally before ssh

end deploy do

Put things that will set up an empty directory into a fully set-up

# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
to :launch do
  queue "mkdir -p #{deploy_to}/#{current_path}/tmp/"
  queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt"
end

end end

fahmiardhianto commented 8 years ago

One assumption that I strongly believe is that when doing assets precompilation, server use lot of memory and crashed. My VPS memory back then just 512MB and then I upgrade my VPS memory to 1GB. After the upgrade, till today, I only failed once and restarting VPS solve the problem.

frgooall commented 8 years ago

@fahmiardhianto Yup, that was the issue! Once I upgraded not having that error. Thanks!

tommyalvarez commented 7 years ago

@fahmiardhianto After hours of trying to find javascript errors, you saved me. I was used to receive a "No memory" error during precompilation, not a runtimeerror: 1, pretty bad error description.... Thank you so much

mrj commented 7 years ago

Thank you for the out-of-memory explanation. My cause: I forgot to add the swap file to /etc/fstab.

rahul1095 commented 6 years ago

Use therubyracer gem