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

Installing gems with sudo disregarding settings #6

Open
simaob opened this issue Jun 4, 2014 · 1 comment
Open

Installing gems with sudo disregarding settings #6

simaob opened this issue Jun 4, 2014 · 1 comment

Comments

@simaob
Copy link

simaob commented Jun 4, 2014

We were trying to deploy an application built with Rails 2.3.18, which does not use bundler, and uses rvm in the server and we came across an issue related with the brightbox gem, namely with this line: https://github.com/brightbox/brightbox-deployment/blob/master/lib/brightbox/recipes/gems.rb#L33

def install_gem(gem, version, options = nil)
  source_arg = options && options[:source] ? "--source #{options[:source]}" : ""
  run %Q{sh -c "
   gem spec #{gem} --version '#{version}' 2>/dev/null|egrep -q '^name:' ||
   sudo -p '#{sudo_prompt}' gem install --no-ri --no-rdoc --version '#{version}' #{source_arg} #{gem}"
  }
end

Here gems are installed using sudo regardless of the settings that we define in our deploy.rb file.

I would propose changing it to:

def install_gem(gem, version, options = nil)
  source_arg = options && options[:source] ? "--source #{options[:source]}" : ""
  run %Q{sh -c "
    gem spec #{gem} --version '#{version}' 2>/dev/null|egrep -q '^name:' ||
    #{if use_sudo then "sudo -p '#{sudo_prompt}'" end} gem install --no-ri --no-rdoc --version '#{version}' #{source_arg} #{gem}"
  }
end

Or something along those lines.

Cheers and good work with the Brightbox gem. :)

@simaob
Copy link
Author

simaob commented Jun 4, 2014

Just realised that Capistrano v3 doesn't use this variable at all. But they also mention that they don't use sudo at all in the different tasks. So it might be worth removing it possibly, depending if you aim to support Capistrano v3 or v2. Issue @ capistrano: capistrano/capistrano#920

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

No branches or pull requests

1 participant