简体   繁体   中英

Ubuntu/Aptana/WEBrick Ruby/Rails version with and without sudo dont match

I am using Ubuntu 14, Aptana Studio 3 and WEBrick 1.3.1 for Ruby on Rails (installed by https://gorails.com/setup/ubuntu/14.10 )

I noticed that there is a difference between sudo and non-sudo ruby/rails.

$ ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [i686-linux]
$ rails -v
sRails 4.2.0
$ sudo ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [i686-linux]
$ sudo rails -v
Rails 3.2.16

The problem is that Aptana is running WEBrick with the old sudo version of Rails which causes a number of issues. Can you please suggest how to either update the sudo Ruby (which might not be a good idea since it seems to be used somewhere in the system) or how to make WEBrick use correct updated version of Ruby and Rails or how to make Aptana start server without sudo?

How to update ruby see here How to install Ruby 2 on Ubuntu without RVM

I'm recommending to install ruby v >= 2.2.0

sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget http://ftp.ruby-lang.org/pub/ruby/2.2/ruby-2.2.0.tar.gz 
tar -xvzf ruby-2.2.0.tar.gz
cd ruby-2.2.0/
sudo ./configure --prefix=/usr/local
sudo make
sudo make install

You probably are loosing the environment variables when calling sudo

You can keep your environment variables with sudo by using the -E switch:

From the manual:

 -E, --preserve-env

     Indicates to the security policy that the user wishes to preserve their existing environment variables.  The security policy may
     return an error if the user does not have permission to preserve the environment.

So try:

sudo -E ruby -v

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM