koenpunt / capistrano-nvm Goto Github PK
View Code? Open in Web Editor NEWnvm support for Capistrano 3.x
nvm support for Capistrano 3.x
Hi there!
It looks like capistrano-nvm
is not playing well with Rails 5.1 Webpacker.
Rails started make ./bin/yarn
a dependency for assets:precompile here: rails/rails@b1c08d8
.bin/yarn
looks like this:
#!/usr/bin/env ruby
VENDOR_PATH = File.expand_path('..', __dir__)
Dir.chdir(VENDOR_PATH) do
begin
exec "yarnpkg #{ARGV.join(" ")}"
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end
As you can see it does a direct system call to yarnpkg
which is not found in the PATH. I am not sure what's the best way to go around this as Capistrano is not setting environment variables globally but use SSHKit
instead. Any idea?
Thx for your help!
Hello again, one more issue:
undle exec cap staging setup
DEBUG [3e530f1b] Running /usr/bin/env [ -d ~/.rbenv/versions/2.2.3 ] as [email protected]
DEBUG [3e530f1b] Command: [ -d ~/.rbenv/versions/2.2.3 ]
DEBUG [3e530f1b] Finished in 1.660 seconds with exit status 0 (successful).
DEBUG [694d954e] Running /usr/bin/env which passenger as [email protected]
DEBUG [694d954e] Command: /usr/bin/env which passenger
DEBUG [694d954e] /usr/bin/passenger
DEBUG [694d954e] Finished in 0.139 seconds with exit status 0 (successful).
INFO [0f75f9a0] Running /usr/bin/env mkdir -p /tmp/pufffer/ as [email protected]
DEBUG [0f75f9a0] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.3 /usr/bin/env mkdir -p /tmp/pufffer/ )
INFO [0f75f9a0] Finished in 0.136 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 [41dd1f42] Running /usr/bin/env chmod +x /tmp/pufffer/nvm-exec.sh as [email protected]
DEBUG [41dd1f42] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.3 /usr/bin/env chmod +x /tmp/pufffer/nvm-exec.sh )
INFO [41dd1f42] Finished in 0.140 seconds with exit status 0 (successful).
INFO [da2fe3f3] Running /usr/bin/env /tmp/pufffer/nvm-exec.sh as [email protected]
DEBUG [da2fe3f3] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.3 /usr/bin/env /tmp/pufffer/nvm-exec.sh )
DEBUG [da2fe3f3] No .nvmrc file found
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: /tmp/pufffer/nvm-exec.sh exit status: 1
/tmp/pufffer/nvm-exec.sh stdout: Nothing written
/tmp/pufffer/nvm-exec.sh stderr: No .nvmrc file found
SSHKit::Command::Failed: /tmp/pufffer/nvm-exec.sh exit status: 1
/tmp/pufffer/nvm-exec.sh stdout: Nothing written
/tmp/pufffer/nvm-exec.sh stderr: No .nvmrc file found
Tasks: TOP => nvm:validate => nvm:wrapper
(See full trace by running task with --trace)
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?
https://github.com/koenpunt/capistrano-nvm/blob/master/lib/capistrano/tasks/nvm.cap#L31
In the latest version (v0.30.2) of nvm, this /tmp/.../nvm-exec.sh
doesn't work.
Because /usr/local/nvm/nvm.sh
removes arguments now:
nvm-sh/nvm@v0.30.1...v0.30.2#diff-e1e8e036966ad5aaf7709712cd5d8ee3R2372
For example:
nvm-echo.sh:
#!/bin/bash
source "/usr/local/nvm/nvm.sh"
echo "$@"
$ ./nvm-echo.sh node --version
node --version
$ ./nvm-echo.sh node --version
# it displays nothing
You can avoid this issue by setting nvm_prefix
option:
set :nvm_prefix, "#{fetch(:nvm_path)}/nvm-exec"
I'll send a pull request later.
I've been trying to get my application deployed with Capistrano using nvm but it fails the nvm:validate
task:
ERROR nvm: v0.12.5 is not installed or not found in $HOME/.nvm/v0.12.5
The problem is that NVM installs node to .nvm/versions/node/<version>
instead
i added the following lines to my deploy/staging.rb
set :nvm_type, :user # or :system, depends on your nvm setup
set :nvm_node, 'v8.17.0'
set :nvm_map_bins, %w{node npm yarn}
added also require "capistrano/nvm"
in my Capfile then i hit cap staging delploy the nvm:wrapper seemed to be running successfully but when compiling assets i can see
gyp ERR! node -v v14.5.0
which means that node version is not being changed to 8.17.0
any help ?
task :start do
on roles(:app) do
execute :which, "node"
execute :echo, "$PATH"
execute "node --version"
end
end
INFO [3b311430] Running /usr/bin/env which node on 192.168.1.160
DEBUG [3b311430] Command: ( PATH=/home/deploy/.nvm/v0.10.28/bin:$PATH NODE_VERSI
ON=v0.10.28 /usr/bin/env which node )
DEBUG [3b311430] /home/deploy/.nvm/v0.10.28/bin/node
INFO [3b311430] Finished in 0.032 seconds with exit status 0 (successful).
INFO [41231ec4] Running /usr/bin/env echo $PATH on 192.168.1.160
DEBUG [41231ec4] Command: ( PATH=/home/deploy/.nvm/v0.10.28/bin:$PATH NODE_VERSI
ON=v0.10.28 /usr/bin/env echo $PATH )
DEBUG [41231ec4] /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:
/bin:/usr/games
INFO [41231ec4] Finished in 0.056 seconds with exit status 0 (successful).
INFO [55a9c16b] Running /usr/bin/env node --version on 192.168.1.160
DEBUG [55a9c16b] Command: node --version
DEBUG [55a9c16b] bash: node: ���������������
cap aborted!
SSHKit::Command::Failed: node --version exit status: 127
node --version stdout: Nothing written
node --version stderr: bash: node: ���������������
D:/Ruby200/lib/ruby/gems/2.0.0/gems/sshkit-1.4.0/lib/sshkit/command.rb:98:in `ex
it_status='
D:/Ruby200/lib/ruby/gems/2.0.0/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:1
42:in `block (4 levels) in _execute'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/channel
.rb:551:in `call'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/channel
.rb:551:in `do_request'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:561:in `channel_request'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:465:in `dispatch_incoming_packets'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:221:in `preprocess'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:205:in `process'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:169:in `block in loop'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:169:in `loop'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:169:in `loop'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/channel
.rb:269:in `wait'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:1
64:in `block (2 levels) in _execute'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/channel
.rb:514:in `call'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/channel
.rb:514:in `do_open_confirmation'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:545:in `channel_open_confirmation'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:465:in `dispatch_incoming_packets'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:221:in `preprocess'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:205:in `process'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:169:in `block in loop'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:169:in `loop'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/net-ssh-2.9.0/lib/net/ssh/connection/session
.rb:169:in `loop'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:1
66:in `block in _execute'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:1
23:in `tap'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:1
23:in `_execute'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:6
6:in `execute'
E:/westward-server/game-server/lib/capistrano/tasks/westward.rake:21:in `block (
3 levels) in <top (required)>'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:5
4:in `instance_exec'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:5
4:in `run'
D:/Ruby200/lib/ruby/gems/2.0.0/gems/sshkit-1.4.0/lib/sshkit/runners/parallel.rb:
12:in `block (2 levels) in execute'
Tasks: TOP => deploy:start
Might be a dumb question, but if I installed NVM in /home/myuser/.nvm
how can I set it correctly?
This doesn't seem to work...
# Rails app --> deploy.rb
set :nvm_custom_path, '/home/myuser/.nvm'
The documentation isn't so clear and I cannot understand if I am wrong or if the problem I get comes from something else.
Hi,
I've started using this gem but I've noticed some features that I require (install node #27) are not present on the released versions.
Are you looking for maintainers for the project?
Thank you for the nice capistrano gem :)
It would be great to have the possibility to configure only the major version like:
set :nvm_node, 'v18'
By the way, thank you for your work on this gem.
I have some non-node tasks that should not (or at least don't need to) be wrapped to use nvm. Is there a way to exclude certain tasks from having the nvm setup commands run?
Hi, I'm deploying a Rails app that makes use of bower and nvm. The problem I'm having now, is that it appears that Capistrano is not running nvm.sh, without being able to find node during bower:install.
Does anyone know what the problem is here?
Capistrano output:
https://gist.github.com/ngw/5e6491071ef1ee364cebcd61b1347d38
Gemfile.lock:
https://gist.github.com/ngw/8b5b862915c288f618cd3420e707b598
Deploy.rb:
https://gist.github.com/ngw/3472dc3a2fac385da3f9c616a8f5a7a8
Does anybody have any idea what's happening here?
I have multiple Rails applications running on single VPS, each of them deployed under different user.
capistrano-nvm
fails on nvm-exec.sh
manipulation, since it is already created in /tmp/<application>
and belongs to another user.
Simple config option for the file destination would suffice.
Or better clean it up after deploy? (I haven't read the code thoroughly, so I'm not even sure, what the file is for.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.