capistrano / rvm

MIT License
140 stars 47 forks source link

capistrano/rvm fails with system wide rvm instalation #13

Closed sauliusgrigaitis closed 10 years ago

sauliusgrigaitis commented 10 years ago

I'm porting capistrano 2 + rvm-capistrano deployment to capitrano 3 + capistrano/rvm. I use system wide rvm instalation and unprivileged user for deployment. Looks like capistrano/rvm tries to write to system wide rvm installation:

** Invoke rvm:hook (first_time)
** Execute rvm:hook
** Invoke rvm:init (first_time)
** Execute rvm:init
** Invoke rvm:create_wrappers (first_time)
** Execute rvm:create_wrappers
 INFO [a80551dd] Running /usr/local/rvm/bin/rvm wrapper 2.0.0-p247 app_name bundle gem rake ruby on app.domain.com
DEBUG [a80551dd] Command: /usr/local/rvm/bin/rvm wrapper 2.0.0-p247 app_name bundle gem rake ruby
DEBUG [a80551dd]    No bin path suitable for lining wrapper. Try setting 'rvm_bin_path'.
cap aborted!
rvm stdout: Nothing written
rvm stderr: Nothing written
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/command.rb:94:in `exit_status='
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:147:in `block (2 levels) in _execute'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `call'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:149:in `block in _execute'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `tap'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `_execute'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:54:in `execute'
/home/user/.rvm/gems/ruby-2.0.0-p247/bundler/gems/rvm-05e37c4ec2f6/lib/capistrano/tasks/rvm.rake:68:in `block (3 levels) in <top (required)>'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `run'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => rvm:create_wrappers
mpapis commented 10 years ago

looks like you need mixed mode installation, it was merged in #10 - on the remote system as user run:

rvm user wrappers # just wrappers OR:
rvm user gemsets  # wrappers and gemsets

but then I think it still should have been changed to use wrappers path instead of bins ...

sauliusgrigaitis commented 10 years ago

For some reason creating wrappers doesn't work (RVM bug?):

$ rvm user wrappers
Unrecognized option 'wrappers'.
Usage: rvm user [[gemsets] [rubies] [hooks] [pkgs] [wrappers] [all] [--skel]|none]

though creating gemsets works fine with:

rvm user gemsets

In any case, this wrapper creation thing should be at least mentioned in documentation near :mixed mode. I can't see why these wrappers can't be created automatically by capistrano/rvm in :mixed mode.

I also suggest to clearly write that :mixed mode should be used with system wide RVM installations and unprivileged deploy users. It will be more clear for folks that come from rvm-capistrano, where this setup needs :system mode.

Now I get missing bundler gem problem. Not sure where capistrano/rvm looks for that gem, but bundler is installed in all gemsets...

** Invoke bundler:install (first_time)
** Execute bundler:install
DEBUG [8cddaa48] Running if test ! -d /path/to/app/releases/20131017074541; then echo "Directory does not exist '/path/to/app/releases/20131017074541'" 1>&2; false; fi on domain.com
DEBUG [8cddaa48] Command: if test ! -d /path/to/app/releases/20131017074541; then echo "Directory does not exist '/path/to/app/releases/20131017074541'" 1>&2; false; fi
DEBUG [8cddaa48] Finished in 1.379 seconds command successful.
 INFO [3d3adb4f] Running ~/.rvm/bin/app_bundle --gemfile /path/to/app/releases/20131017074541/Gemfile --path /path/to/app/shared/bundle --deployment --quiet --binstubs /path/to/app/shared/bin --without development test on domain.com
DEBUG [3d3adb4f] Command: cd /path/to/app/releases/20131017074541 && ( PATH=/home/user/.rvm/bin:$PATH ~/.rvm/bin/app_bundle --gemfile /path/to/app/releases/20131017074541/Gemfile --path /path/to/app/shared/bundle --deployment --quiet --binstubs /path/to/app/shared/bin --without development test )
DEBUG [3d3adb4f]        ERROR: Gem bundler is not installed, run `gem install bundler` first.
cap aborted!
bundle stdout: Nothing written
bundle stderr: Nothing written
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/command.rb:94:in `exit_status='
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:147:in `block (2 levels) in _execute'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `call'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh
kirs commented 10 years ago

@sauliusgrigaitis could you try this fork?

sauliusgrigaitis commented 10 years ago

Thanks, but it still throws an error. Now bundler doesn't find gems that it successfully installed.

** Invoke deploy:compile_assets (first_time)
** Execute deploy:compile_assets
** Invoke deploy:assets:precompile (first_time)
** Execute deploy:assets:precompile
DEBUG [f00c64ed] Running if test ! -d /path/to/app/releases/20131017123146; then echo "Directory does not exist '/path/to/app/releases/20131017123146'" 1>&2; false; fi on domain.com
DEBUG [f00c64ed] Command: if test ! -d /path/to/app/releases/20131017123146; then echo "Directory does not exist '/path/to/app/releases/20131017123146'" 1>&2; false; fi
DEBUG [f00c64ed] Finished in 1.391 seconds command successful.
 INFO [c4d8f448] Running /usr/local/rvm/bin/rvm 2.0.0-p247 do rake assets:precompile on domain.com
DEBUG [c4d8f448] Command: cd /path/to/app/releases/20131017123146 && ( RAILS_ENV=staging /usr/local/rvm/bin/rvm 2.0.0-p247 do rake assets:precompile )
DEBUG [c4d8f448]    /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
DEBUG [c4d8f448]    : 
DEBUG [c4d8f448]    Could not find i18n-0.6.5 in any of the sources
DEBUG [c4d8f448]     (
DEBUG [c4d8f448]    Bundler::GemNotFound
DEBUG [c4d8f448]    )
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `map!'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `materialize'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:159:in `specs_for'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:148:in `requested_specs'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/environment.rb:18:in `requested_specs'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:13:in `setup'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/rubygems-bundler-1.3.4/lib/rubygems-bundler/noexec.rb:74:in `setup'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/rubygems-bundler-1.3.4/lib/rubygems-bundler/noexec.rb:103:in `check'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/rubygems-bundler-1.3.4/lib/rubygems-bundler/noexec.rb:109:in `<top (required)>'
DEBUG [c4d8f448]        from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
DEBUG [c4d8f448]        from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
DEBUG [c4d8f448]        from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/rubygems-bundler-1.3.4/lib/rubygems_executable_plugin.rb:4:in `block in <top (required)>'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/executable-hooks-1.2.5/lib/executable-hooks/hooks.rb:50:in `call'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/executable-hooks-1.2.5/lib/executable-hooks/hooks.rb:50:in `block in run'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/executable-hooks-1.2.5/lib/executable-hooks/hooks.rb:49:in `each'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/executable-hooks-1.2.5/lib/executable-hooks/hooks.rb:49:in `run'
DEBUG [c4d8f448]        from /usr/local/rvm/gems/ruby-2.0.0-p247@global/bin/ruby_executable_hooks:10:in `<main>'
cap aborted!
rake stdout: Nothing written
rake stderr: Nothing written
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/command.rb:94:in `exit_status='
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:147:in `block (2 levels) in _execute'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `call'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:149:in `block in _execute'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `tap'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `_execute'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:54:in `execute'
/home/user/.rvm/gems/ruby-2.0.0-p247/bundler/gems/rails-1fbdf376f0b1/lib/capistrano/tasks/assets.rake:61:in `block (6 levels) in <top (required)>'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/abstract.rb:89:in `with'
/home/user/.rvm/gems/ruby-2.0.0-p247/bundler/gems/rails-1fbdf376f0b1/lib/capistrano/tasks/assets.rake:60:in `block (5 levels) in <top (required)>'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/abstract.rb:81:in `within'
/home/user/.rvm/gems/ruby-2.0.0-p247/bundler/gems/rails-1fbdf376f0b1/lib/capistrano/tasks/assets.rake:59:in `block (4 levels) in <top (required)>'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `run'
/home/user/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => deploy:assets:precompile
mpapis commented 10 years ago

I do not see bundle install before that, are you sure the gems are installed?

sauliusgrigaitis commented 10 years ago

It's not full deployment log for sure. Gems are installed without any problems. Assets precompilation works fine when I run that rake task directly on server. Can you guys reproduce it? It would be much faster to fix it.

* Invoke bundler:install (first_time)
** Execute bundler:install
DEBUG [6a1cb39d] Running if test ! -d /path/to/app/releases/20131017123146; then echo "Directory does not exist '/path/to/app/releases/20131017123146'" 1>&2; false; fi on domain.com
DEBUG [6a1cb39d] Command: if test ! -d /path/to/app/releases/20131017123146; then echo "Directory does not exist '/path/to/app/releases/20131017123146'" 1>&2; false; fi
DEBUG [6a1cb39d] Finished in 1.260 seconds command successful.
 INFO [dd21e8f5] Running /usr/local/rvm/bin/rvm 2.0.0-p247 do bundle --gemfile /path/to/app/releases/20131017123146/Gemfile --path /path/to/app/shared/bundle --deployment --quiet --binstubs /path/to/app/shared/bin --without development test on domain.com
DEBUG [dd21e8f5] Command: cd /path/to/app/releases/20131017123146 && /usr/local/rvm/bin/rvm 2.0.0-p247 do bundle --gemfile /path/to/app/releases/20131017123146/Gemfile --path /path/to/app/shared/bundle --deployment --quiet --binstubs /path/to/app/shared/bin --without development test
 INFO [dd21e8f5] Finished in 3.435 seconds command successful.
** Execute deploy:updated
** Invoke deploy:compile_assets (first_time)
** Execute deploy:compile_assets
mpapis commented 10 years ago

this are two conflicting processes, you just installed gems using --path /path/to/app/shared/bundle then the gems are not available in standard $GEM_PATH, you would need to modify the rake command to be:

/usr/local/rvm/bin/rvm 2.0.0-p247 do bundle exec rake assets:precompile on domain.com
sauliusgrigaitis commented 10 years ago

Any ideas how to that?

SSHKit.config.command_map[:rake] = "bundle exec rake" doesn't help really:

 INFO [01189de2] Running bundle exec rake assets:precompile on domain.com
DEBUG [01189de2] Command: cd /path/to/app/releases/20131017134713 && ( RAILS_ENV=staging bundle exec rake assets:precompile )
DEBUG [01189de2]    bash: bundle: command not found
cap aborted!
mpapis commented 10 years ago

try:

SSHKit.config.command_map[:rake] ||= "rake"
SSHKit.config.command_map[:rake].sub!(/\(.*\)rake/, "\1bundle exec rake")
sauliusgrigaitis commented 10 years ago

Thanks for trick, but it looks like endless ping pong game.

 INFO [a2891cd2] Running /bin/rvm  do rake assets:precompile on domain.com
DEBUG [a2891cd2] Command: cd /path/to/app/releases/20131017144719 && ( RAILS_ENV=staging /bin/rvm  do rake assets:precompile )
DEBUG [a2891cd2]    bash: /bin/rvm: No such file or directory
cap aborted!
mpapis commented 10 years ago

I think this is related to https://github.com/capistrano/rvm/issues/12#issuecomment-26512659

tolhzar commented 10 years ago

Guys, I managed to fix this using the following task:

  task :set_sshkit_config do
    SSHKit.config.command_map[:rake]  = "#{fetch(:rvm_path)}/bin/#{fetch(:application)}_bundle exec rake"
    SSHKit.config.command_map[:rails] = "#{fetch(:rvm_path)}/bin/#{fetch(:application)}_bundle exec rails"
  end
  after "rvm:hook", "deploy:set_sshkit_config"

Not sure about place I run task. Just wanted to use

rvm_path
and not to write manually
~/.rvm/bin
However if you set config like
SSHKit.config.command_map[:rake]  = "~/.rvm/bin/#{fetch(:application)}_bundle exec rake"
you won't need to use a task, simply put this into deploy.rb.

What do you think?

leehambley commented 10 years ago

That's exactly how we planned the command map to work, it's a shame you've had to brute-force it, but I'm glad that you could a workaround.

It looks like there's more, stranger rvm installs in the wild than we predicted. @kirs, thoughts?

sauliusgrigaitis commented 10 years ago

@rocketblr should I run this in :mixed mode? As you see from previous discussion :mixed mode doesn't work. Also I really don't want to use rvm in :user mode, because it leads to complication in my setups.

@leehambley what is strange with such rvm install? This is most natural way that works perfectly well (I have ~50 such installations). So ruby and rvm is system wide and controlled by server admin only (just like python, java etc.) and gems are installed by unprivileged deploy user using bundler in shared app dir. In this case I don't have any problems running multiple apps by multiple users at same server. Also there is no problem running ruby services from monit etc. when ruby is system wide. I see this setup as most natural way, would be great to hear some arguments against such setup.

tolhzar commented 10 years ago

@sauliusgrigaitis as soon as capistrano-rvm do this

  task :init do
    on roles(:all) do
      rvm_path = fetch(:rvm_custom_path)
      rvm_path ||= case fetch(:rvm_type)
      when :auto
        if test("[ -d #{RVM_SYSTEM_PATH} ]")
          RVM_SYSTEM_PATH
        else
          RVM_USER_PATH
        end
      when :system, :mixed
        RVM_SYSTEM_PATH
      else # :user
        RVM_USER_PATH
      end
      set :rvm_path, rvm_path
      set :rvm_bins_path, fetch(:rvm_type) == :mixed ? RVM_USER_PATH : rvm_path
      rvm_ruby_version = fetch(:rvm_ruby_version)
      rvm_ruby_version ||= capture(:rvm, "current")
      set :rvm_ruby_version, rvm_ruby_version
    end
  end

you can try to change #{fetch(:rvm_path)} to #{fetch(:rvm_bins_path)} to make it work in mixed mode. I'm afraid I don't have any suitable environment to test.

charandas commented 10 years ago

Mixed mode works without issues for me using the fork kirs recommended above in (pull request)[https://github.com/capistrano/rvm/pull/16]. Obviously, its no longer called "mixed". Just use set :rvm_type, :system in your stage configurations.

All ruby calls (bundle, rake, et cetera) would be called using rvm do if you use this fork. Cannot wait before it gets merged.

sauliusgrigaitis commented 10 years ago

@kbdaitch do you use it for Rails deployment? You are correct that now commands are called using rvm do , but capistrano/rails still doesn't place bundle in assets compilation.

charandas commented 10 years ago

@sauliusgrigaitis I use it for rails deployment. My asset compilation passes. That is a proof enough that it must be using rvm do bundle exec rake assets:precompile.

I will double check tomorrow when I run a deploy.

charandas commented 10 years ago

@sauliusgrigaitis You were right. It is indeed not using bundle in asset compilation. Are we missing a clue here when using system mode? Its just rvm do rake assets:precompile that is being executed at that stage.

sauliusgrigaitis commented 10 years ago

I switched to rvm1-capistrano3 yesterday, works perfectly so far.

kirs commented 10 years ago

What do you mean under rvm1-capistrano3?

Kir Shatrov +7 (929) 631-46-35

On Tuesday 29 October 2013 at 18:31, Saulius Grigaitis wrote:

I switched to rvm1-capistrano3 yesterday, works perfectly so far.

— Reply to this email directly or view it on GitHub (https://github.com/capistrano/rvm/issues/13#issuecomment-27307449).

mpapis commented 10 years ago

https://github.com/rvm/rvm1-capistrano3

zapnap commented 10 years ago

For anyone else just stumbling on this, I had the same issue with bundle exec not getting used for asset compilation (was wrapped in an rvm do block but no be inside). rvm1-capistrano3 resolved the issue immediately for me.