Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is nvm-exec.sh actually executed? #10

Open
lessless opened this issue Dec 15, 2015 · 6 comments
Open

Is nvm-exec.sh actually executed? #10

lessless opened this issue Dec 15, 2015 · 6 comments

Comments

@lessless
Copy link

Hello folks,
got a weird behavior today:

cap staging deploy:check_node
DEBUG [fd22af91] Running /usr/bin/env [ -d ~/.rbenv/versions/2.2.3 ] as [email protected]
DEBUG [fd22af91] Command: [ -d ~/.rbenv/versions/2.2.3 ]
DEBUG [fd22af91] Finished in 1.404 seconds with exit status 0 (successful).
DEBUG [3dd24079] Running /usr/bin/env which passenger as [email protected]
DEBUG [3dd24079] Command: /usr/bin/env which passenger
DEBUG [3dd24079]  /usr/bin/passenger
DEBUG [3dd24079] Finished in 0.154 seconds with exit status 0 (successful).
INFO [460633f5] Running /usr/bin/env mkdir -p /tmp/pufffer/ as [email protected]
DEBUG [460633f5] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.3 /usr/bin/env mkdir -p /tmp/pufffer/ )
INFO [460633f5] Finished in 0.155 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/pufffer/nvm-exec.sh 0.0%
INFO Uploading /tmp/pufffer/nvm-exec.sh 100.0%
INFO [9928c04c] Running /usr/bin/env chmod +x /tmp/pufffer/nvm-exec.sh as [email protected]
DEBUG [9928c04c] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.3 /usr/bin/env chmod +x /tmp/pufffer/nvm-exec.sh )
INFO [9928c04c] Finished in 0.165 seconds with exit status 0 (successful).
DEBUG [f6a94bbe] Running /usr/bin/env [ -d $HOME/.nvm/v5.1.1 ] || [ -d $HOME/.nvm/versions/node/v5.1.1 ] as [email protected]
DEBUG [f6a94bbe] Command: [ -d $HOME/.nvm/v5.1.1 ] || [ -d $HOME/.nvm/versions/node/v5.1.1 ]
DEBUG [f6a94bbe] Finished in 0.163 seconds with exit status 0 (successful).
DEBUG [139d442d] Running /usr/bin/env node -v as [email protected]
DEBUG [139d442d] Command: node -v
DEBUG [139d442d]  bash: node: command not found
DEBUG [139d442d] Finished in 0.154 seconds with exit status 127 (failed).

as you can see /tmp/pufffer/nvm-exec.sh actually wasn't executed, and I can't find command to do that anywhere in

Deploy on staging failing as well:

BUG [5318c3ec] Command: cd /var/www/puffer/releases/20151215012855 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.3 NODE_VERSION=v5.1.1 RAILS_ENV=staging ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )
DEBUG [5318c3ec]  rake aborted!
DEBUG [5318c3ec]  ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
DEBUG [5318c3ec]  /var/www/puffer/shared/bundle/ruby/2.2.0/gems/execjs-2.6.0/lib/execjs/runtimes.rb:48:in `autodetect'
DEBUG [5318c3ec]  /var/www/puffer/shared/bundle/ruby/2.2.0/gems/execjs-2.6.0/lib/execjs.rb:5:in `<module:ExecJS>'
DEBUG [5318c3ec]  /var/www/puffer/shared/bundle/ruby/2.2.0/gems/execjs-2.6.0/lib/execjs.rb:4:in `<top (required)>'
DEBUG [5318c3ec]  /var/www/puffer/shared/bundle/ruby/2.2.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `require'
DEBUG [5318c3ec]  /var/www/puffer/shared/bundle/ruby/2.2.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `<top (required)>'
DEBUG [5318c3ec]  /var/www/puffer/releases/20151215012855/config/application.rb:7:in `<top (required)>'
DEBUG [5318c3ec]  /var/www/puffer/releases/20151215012855/Rakefile:4:in `require'
DEBUG [5318c3ec]  /var/www/puffer/releases/20151215012855/Rakefile:4:in `<top (required)>'
DEBUG [5318c3ec]  (See full trace by running task with --trace)
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
/var/www/puffer/shared/bundle/ruby/2.2.0/gems/execjs-2.6.0/lib/execjs/runtimes.rb:48:in `autodetect'
/var/www/puffer/shared/bundle/ruby/2.2.0/gems/execjs-2.6.0/lib/execjs.rb:5:in `<module:ExecJS>'
/var/www/puffer/shared/bundle/ruby/2.2.0/gems/execjs-2.6.0/lib/execjs.rb:4:in `<top (required)>'
/var/www/puffer/shared/bundle/ruby/2.2.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `require'
/var/www/puffer/shared/bundle/ruby/2.2.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `<top (required)>'
/var/www/puffer/releases/20151215012855/config/application.rb:7:in `<top (required)>'
/var/www/puffer/releases/20151215012855/Rakefile:4:in `require'
/var/www/puffer/releases/20151215012855/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

Is it a bug or I'm missing something?

@lessless lessless changed the title Is it nvm-exec.sh actually executed? Is nvm-exec.sh actually executed? Dec 15, 2015
@kayakyakr
Copy link

So the only two commands that are run under nvm by default are node and npm. To run your check_node task, you want to add

set :nvm_map_bins, %w{node npm which}

For my own rails + ember-cli deploy, I've had to add rake bundle ruby. I'd love to figure out a way that I can run it only for specific tasks, but it seems like that implementation still depends on the bins.

I also want to remove the automatic validate check as it actually prevents being able to install nvm through capistrano.

@koenpunt
Copy link
Owner

I think @kayakyakr answer does answer the question?

@lucaspiller
Copy link

This didn't work in my case. I'm also using capistrano-rbenv. The wrapper expects to be passed a command, rbenv makes it a bit more complicated:

  00:23 bundler:install
        01 /tmp/myapp/nvm-exec.sh RBENV_ROOT=$HOME/.rbenv RBENV_VERSION=2.3.1 $HOME/.rbenv/bin/rbenv exec bundle install --path /home/myapp/shared/bundle --without development test --deployment --binstubs /home/myapp/bin
        01 Now using node v6.9.0 (npm v3.10.8)
        01 /tmp/myapp/nvm-exec.sh: line 4: /home/myapp/releases/20161019150031/RBENV_ROOT=/home/myapp/.rbenv: No such file or directory

@krsyoung
Copy link

krsyoung commented Mar 23, 2017

@lucaspiller I've just landed in the same boat. Any chance you managed to get around it?

I should add that I've been able to manually get around it by changing the order of things. In my case this works:

RBENV_ROOT=$HOME/.rbenv RBENV_VERSION=2.3.3 /tmp/yes/nvm-exec.sh $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile

Just need to figure out how to get that to work with Capistrano :-)

@fastman
Copy link

fastman commented Oct 30, 2017

@krsyoung What I'm using is:

Rails 4, Capistrano 3.x, Node.js v6

Capfile:

require 'capistrano/setup'

require 'capistrano/deploy'

require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git

# Mind the order - nvm comes first, before rbenv
require 'capistrano/nvm'
require 'capistrano/npm'

require 'capistrano/rbenv'

require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

require 'capistrano3/unicorn'
require 'capistrano/delayed-job'

Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

deploy.rb:

lock '3.10.0'
(...)
set :linked_dirs, %w{bin log node_modules tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
(...)

set :rbenv_type, :user
set :rbenv_ruby, File.read('.ruby-version').strip
set :rbenv_prefix, -> { "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:nvm_prefix)} #{fetch(:rbenv_path)}/bin/rbenv exec" }
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all # default value

set :nvm_type, :user # or :system, depends on your nvm setup
set :nvm_node, File.read('.nvmrc').strip
set :nvm_map_bins, %w{node npm}
set :nvm_roles, :web

set :npm_roles, :web

Also, I do not have any default version of Node.js set in nvm.
Hope this helps!

@krsyoung
Copy link

Thanks @fastman, need to dust off some code and will give it a try. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants