MeltingDog
MeltingDog

Reputation: 15488

'sudo ruby setup.rb' won't install Gems on Vagrant box

I'm new to using Vagrant and am trying to install Gems on it (Ruby is already installed). I am following the instructions here.

I've downloaded the latest version of Gems and extracted it. I have "cd'd" into that folder and have tried to run:

ruby setup.rb

But get a Permission denied error, so I try sudo:

sudo ruby setup.rb

But this gives me the error:

sudo: ruby: command not found

Would anyone know what's going on here?

Edit - more info

I checked the version of ruby and its 2.3.0p0.

If I try to check the version of Gems is says to install Ruby 1.9.1.

I don't really understand this...

Upvotes: 1

Views: 253

Answers (2)

TOM
TOM

Reputation: 178

I suggest to you use RMV to install Ruby and Gem versions.

Install RVM

https://rvm.io/

- gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
- \curl -sSL https://get.rvm.io | bash -s stable
- source /home/vagrant/.rvm/scripts/rvm

Install Ruby

rvm get stable --autolibs=enable
rvm install ruby-2.3.1

Use default ruby version

rvm --default use ruby-2.3.1

Upvotes: 0

philomory
philomory

Reputation: 1767

sudo doesn't preserve your $PATH environment variable, so unless ruby is installed somewhere that's in root's path, it's not going to be found.

Run which ruby to find out where ruby is installed, then sudo /path/to/ruby setup.rb

Also, more importantly, that's completely unnecessary. Those instructions are old. Rubygems has been built-in to ruby for a long time now. The site you linked even says, "If you’re on Ruby 1.9.*, then you don’t have to worry about installing Rubygems; it’s built in." If you're on 2.3.0, you don't need to install Rubygems, you have it already.

Upvotes: 1

Related Questions