Ubuntu 12.04 - Capistrano Gem fails to install Ruby with permission denied #43

Closed
Iristyle opened this Issue Dec 6, 2012 · 14 comments

Comments

Projects
None yet
2 participants
@Iristyle

Iristyle commented Dec 6, 2012

Installing RVM as system, followed by Ruby... fails with perm issues during a cap deploy:setup.

The essential issue is that the current user, although added to the rvm group during my Capistrano deploy, has not yet had the umask perms applied. When it comes time to write to /usr/local/rvm, the downloads blow up with permission denied. Executing a logout during cap deploy:setup isn't really an option.

After the initail fail, If I run the cap deploy:setup -v -d and step through to execute just the command necessary to install Ruby, then of course, it works.. as this is a new login session and the perms have applied.

I can think of a couple of potential fixes to handle this.

My config values, for reference

set :rvm_install_type, :stable
set :rvm_install_with_sudo, true
set :rvm_type, :system
set :rvm_ruby_string, '1.9.3'
set :rvm_path, '/usr/local/rvm' #ensure rvm doesn't end up in current users /home
@mpapis

This comment has been minimized.

Show comment Hide comment
@mpapis

mpapis Dec 6, 2012

Member

the problem is user was not added to rvm group after installing rvm - it's no more automated process - in this case it looks like it would be better if it would be automated, I'm thinking on adding a flag for rvm installer to allow adding the user when requested

Member

mpapis commented Dec 6, 2012

the problem is user was not added to rvm group after installing rvm - it's no more automated process - in this case it looks like it would be better if it would be automated, I'm thinking on adding a flag for rvm installer to allow adding the user when requested

@Iristyle

This comment has been minimized.

Show comment Hide comment
@Iristyle

Iristyle Dec 6, 2012

I am adding the users to the rvm group already.

task :add_users_to_rvm_group, :roles => :web do
    run "#{sudo} usermod -aG rvm #{user};#{sudo} usermod -aG rvm #{deploy_user}"
end
before 'rvm:install_ruby', 'deploy:add_users_to_rvm_group'

The issue is that umask is not applying during the current capistrano SSH session.

Iristyle commented Dec 6, 2012

I am adding the users to the rvm group already.

task :add_users_to_rvm_group, :roles => :web do
    run "#{sudo} usermod -aG rvm #{user};#{sudo} usermod -aG rvm #{deploy_user}"
end
before 'rvm:install_ruby', 'deploy:add_users_to_rvm_group'

The issue is that umask is not applying during the current capistrano SSH session.

@mpapis

This comment has been minimized.

Show comment Hide comment
@mpapis

mpapis Dec 6, 2012

Member

and it did not help?

Member

mpapis commented Dec 6, 2012

and it did not help?

@Iristyle

This comment has been minimized.

Show comment Hide comment
@Iristyle

Iristyle Dec 6, 2012

During the first cap deploy:setup / SSH session, it fails because the user cannot logout

Once Capistrano dies with the failure, and I run cap deploy:setup again... it's a new session, and the umask is now applying, so it succeeds.

Iristyle commented Dec 6, 2012

During the first cap deploy:setup / SSH session, it fails because the user cannot logout

Once Capistrano dies with the failure, and I run cap deploy:setup again... it's a new session, and the umask is now applying, so it succeeds.

@Iristyle

This comment has been minimized.

Show comment Hide comment
@Iristyle

Iristyle Dec 6, 2012

If I create my own deploy:install_ruby thats uses sudo instead of using the rvm:install_ruby task, it works the first time.

task :install_ruby, :roles => :web do
  run "export CURL_HOME=${TMPDIR:-${HOME}}/.rvm-curl-config.$$; mkdir ${CURL_HOME}/; { [[ -r ${HOME}/.curlrc ]] && cat ${HOME}/.curlrc; echo \"silent\"; echo \"show-error\"; } > $CURL_HOME/.curlrc ; #{sudo} #{rvm_path}/bin/rvm install #{rvm_ruby_string} -j $(cat /proc/cpuinfo | grep vendor_id | wc -l) ; rm -rf $CURL_HOME"
end

Iristyle commented Dec 6, 2012

If I create my own deploy:install_ruby thats uses sudo instead of using the rvm:install_ruby task, it works the first time.

task :install_ruby, :roles => :web do
  run "export CURL_HOME=${TMPDIR:-${HOME}}/.rvm-curl-config.$$; mkdir ${CURL_HOME}/; { [[ -r ${HOME}/.curlrc ]] && cat ${HOME}/.curlrc; echo \"silent\"; echo \"show-error\"; } > $CURL_HOME/.curlrc ; #{sudo} #{rvm_path}/bin/rvm install #{rvm_ruby_string} -j $(cat /proc/cpuinfo | grep vendor_id | wc -l) ; rm -rf $CURL_HOME"
end
@mpapis

This comment has been minimized.

Show comment Hide comment
@mpapis

mpapis Dec 6, 2012

Member

OMG - just learned a new thing about capistrano, this is one connection(session) but run with new shell per command, checking now how to fix it

Member

mpapis commented Dec 6, 2012

OMG - just learned a new thing about capistrano, this is one connection(session) but run with new shell per command, checking now how to fix it

@mpapis

This comment has been minimized.

Show comment Hide comment
@mpapis

mpapis Dec 6, 2012

Member

ok so my preferred solution is prefixing ruby installation command with sg rvm - there needs to be some safeguards, but this should be possible ...

I'm also considering to add:

raise "RVM was just installed in system location, it is required to restart deploy process to make use of the new created 'rvm' group."
Member

mpapis commented Dec 6, 2012

ok so my preferred solution is prefixing ruby installation command with sg rvm - there needs to be some safeguards, but this should be possible ...

I'm also considering to add:

raise "RVM was just installed in system location, it is required to restart deploy process to make use of the new created 'rvm' group."
@Iristyle

This comment has been minimized.

Show comment Hide comment
@Iristyle

Iristyle Dec 6, 2012

Ahh yeah, I think sg rvm should work as well -- I can verify for you to be sure.

Thanks

Iristyle commented Dec 6, 2012

Ahh yeah, I think sg rvm should work as well -- I can verify for you to be sure.

Thanks

@Iristyle

This comment has been minimized.

Show comment Hide comment
@Iristyle

Iristyle Dec 7, 2012

Yes, sg rvm does work... here's the relevant part... make sure to use -c and to quote the command

run "export CURL_HOME=${TMPDIR:-${HOME}}/.rvm-curl-config.$$; mkdir ${CURL_HOME}/; { [[ -r ${HOME}/.curlrc ]] && cat ${HOME}/.curlrc; echo \"silent\"; echo \"show-error\"; } > $CURL_HOME/.curlrc ; sg rvm -c \"#{rvm_path}/bin/rvm install #{rvm_ruby_string} -j $(cat /proc/cpuinfo | grep vendor_id | wc -l)\"; rm -rf $CURL_HOME"

Iristyle commented Dec 7, 2012

Yes, sg rvm does work... here's the relevant part... make sure to use -c and to quote the command

run "export CURL_HOME=${TMPDIR:-${HOME}}/.rvm-curl-config.$$; mkdir ${CURL_HOME}/; { [[ -r ${HOME}/.curlrc ]] && cat ${HOME}/.curlrc; echo \"silent\"; echo \"show-error\"; } > $CURL_HOME/.curlrc ; sg rvm -c \"#{rvm_path}/bin/rvm install #{rvm_ruby_string} -j $(cat /proc/cpuinfo | grep vendor_id | wc -l)\"; rm -rf $CURL_HOME"
@mpapis

This comment has been minimized.

Show comment Hide comment
@mpapis

mpapis Dec 16, 2012

Member

now rvm supports:

./rvm-installer --add-to-rvm-group [user_name,...|all]
Member

mpapis commented Dec 16, 2012

now rvm supports:

./rvm-installer --add-to-rvm-group [user_name,...|all]

@mpapis mpapis closed this in 59fa58b Dec 16, 2012

@mpapis

This comment has been minimized.

Show comment Hide comment
@mpapis

mpapis Dec 16, 2012

Member

please test with:

gem install rvm-capistrano --pre

should install 1.3.0.rc2

Member

mpapis commented Dec 16, 2012

please test with:

gem install rvm-capistrano --pre

should install 1.3.0.rc2

@Iristyle

This comment has been minimized.

Show comment Hide comment
@Iristyle

Iristyle Jan 15, 2013

@mpapis ... Finally verified this works.

Is there a way to lock down the RVM version? I had to change

set :rvm_install_type, :stable

to

set :rvm_install_type, :head

I'd prefer to lock down a version number or similar, so I don't get bit by a future update. Any thoughts?

I tried set :rvm_install_type, '-- --version 1.17.8' but no love there. Here's the result:

  * ←[32m2013-01-15 15:55:57 executing `rvm:install_rvm'←[0m
  * ←[33mexecuting "__LAST_STATUS=0; export CURL_HOME=\"${TMPDIR:-${HOME}}/.rvm-curl-config.$$\"; mkdir ${CURL_HOME}/; { [[ -r ${HOME}/.curlrc ]] && cat ${HOME}/.curlrc; echo \"silent\"; echo \"show-error\"; } > $CURL_HOME/.curlrc; curl -L get.rvm.io | sudo -p 'sudo password: ' bash -s -- --version 1.17.8 --path /usr/local/rvm --add-to-rvm-group ubuntu,user2 || __LAST_STATUS=$?; rm -rf $CURL_HOME; exit ${__LAST_STATUS}"←[0m
    servers: ["ec2-redacted.compute-1.amazonaws.com"]
    [ec2-redacted.compute-1.amazonaws.com] executing command
 ** [out :: ec2-redacted.compute-1.amazonaws.com] Downloading RVM version 1.17.8

<snipped download />

 ** [out :: ec2-redacted.compute-1.amazonaws.com] Unrecognized option: --add-to-rvm-group
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] Usage:
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] ./scripts/install [options]
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] options:
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] --auto    : Automatically update shell profile files.
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] --path    : Installation directory (rvm_path).
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] --help    : Display help/usage (this)
message
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] --version : display rvm package version
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
    ←[2;37mcommand finished in 1064ms←[0m

@mpapis ... Finally verified this works.

Is there a way to lock down the RVM version? I had to change

set :rvm_install_type, :stable

to

set :rvm_install_type, :head

I'd prefer to lock down a version number or similar, so I don't get bit by a future update. Any thoughts?

I tried set :rvm_install_type, '-- --version 1.17.8' but no love there. Here's the result:

  * ←[32m2013-01-15 15:55:57 executing `rvm:install_rvm'←[0m
  * ←[33mexecuting "__LAST_STATUS=0; export CURL_HOME=\"${TMPDIR:-${HOME}}/.rvm-curl-config.$$\"; mkdir ${CURL_HOME}/; { [[ -r ${HOME}/.curlrc ]] && cat ${HOME}/.curlrc; echo \"silent\"; echo \"show-error\"; } > $CURL_HOME/.curlrc; curl -L get.rvm.io | sudo -p 'sudo password: ' bash -s -- --version 1.17.8 --path /usr/local/rvm --add-to-rvm-group ubuntu,user2 || __LAST_STATUS=$?; rm -rf $CURL_HOME; exit ${__LAST_STATUS}"←[0m
    servers: ["ec2-redacted.compute-1.amazonaws.com"]
    [ec2-redacted.compute-1.amazonaws.com] executing command
 ** [out :: ec2-redacted.compute-1.amazonaws.com] Downloading RVM version 1.17.8

<snipped download />

 ** [out :: ec2-redacted.compute-1.amazonaws.com] Unrecognized option: --add-to-rvm-group
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] Usage:
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] ./scripts/install [options]
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] options:
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] --auto    : Automatically update shell profile files.
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] --path    : Installation directory (rvm_path).
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] --help    : Display help/usage (this)
message
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
 ** [out :: ec2-redacted.compute-1.amazonaws.com] --version : display rvm package version
 ** [out :: ec2-redacted.compute-1.amazonaws.com]
    ←[2;37mcommand finished in 1064ms←[0m
@mpapis

This comment has been minimized.

Show comment Hide comment
@mpapis

mpapis Jan 24, 2013

Member

@Iristyle try:

set :rvm_install_type, 'version 1.18.1'

if it does not work open a new ticket

Member

mpapis commented Jan 24, 2013

@Iristyle try:

set :rvm_install_type, 'version 1.18.1'

if it does not work open a new ticket

@mpapis

This comment has been minimized.

Show comment Hide comment
@mpapis

mpapis Jan 24, 2013

Member

also:

set :rvm_install_type, 'latest-1.18'
Member

mpapis commented Jan 24, 2013

also:

set :rvm_install_type, 'latest-1.18'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment