Skip to content

Installing gems with sudo disregarding settings #6

@simaob

Description

@simaob

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. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions