Root privileges to install ruby gems on Openshift

2019-03-01 09:55发布

问题:

How can I get root privileges in my Openshift app? I need to install additional gems to my Openshift virtual machine and it's impossible to do it without superuser privileges.

For login, I'm using SSH: ssh generated-hash@myapp-myns.rhcloud.com

I've already entered my id_key.pub to the Openshift web interface and I'm doing SSH with no password.

回答1:

To install additional gems in openshift see this forum, copied from ramr answer:

So what you would need to do is add a Gemfile + Gemfile.lock to your app and then do a git push -- see https://github.com/openshift/rails-example for an example Gemfile+Gemfile.lock.

Steps to do that: 1. Create an appropriate Gemfile -- probably something like:

source 'http://rubygems.org'  

gem 'whois'  
gem "minitest"  

local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")  
if File.exists?(local_gemfile)  
  puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v`  
  instance_eval File.read(local_gemfile)  
end  

On your workstation do a bundler install bundle install (you might need to gem install bundler before you can use bundler). That should create a Gemfile.lock - add that and the Gemfile and commit git add Gemfile Gemfile.lock, git commit Gemfile Gemfile.lock -m 'added deps' Push changes to your OpenShift App git push HTH