I'm not trying to manage multiple versions of Ruby although I think that's what I have.
When I run ruby -v it says ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15].
However, when I ran brew upgrade ruby it says Ruby didn't exist. Then I did brew install ruby and it installed version 2.4.0. When I run ruby -v it still says the same thing.
How do I just have the most up to date version of Ruby on my computer?
I have a Mac.
Because your PATH link to your origin ruby, you should add your homebrew ruby path to your .bash_profile like this export PATH=${PATH}:${HOMEBREW_HOME}/ruby
The better way that I recommend is using the rvm https://rvm.io/rvm/install
Follow the step to install rvm/ruby
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash
then copy and execute the shell in bash
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
restart the bash and type which ruby, then it return $HOME/.rvm/rubies/ruby-2.3.3/bin/ruby and your ruby work.
Related
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...
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.
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
I have an older mac mini (v10.5.8) I would like to put the latest version of rails on.
gem update --system gives me "no such file to load"
gem install rubygems-update gives me the same thing as above
So I manually downloaded from rubygems.org/pages/download and extracted the tar then tried running ruby setup.rb but that gives me...
./lib/rubygems/core_ext/kernel_require.rb:45:in 'gem_original_require': no such file to load -- stringio (LoadError)
...so I'm stuck now..I'm not sure where to go from here...running ruby -v gives me "1.8.7 (2008-05-31 patchlevel 0"
Instead of using the system ruby, you should try to use rvm to install a recent version of Ruby:
$ curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled --ruby=1.9.3
Or, if you want more control
$ curl -L https://get.rvm.io | bash -s stable
$ rvm get head
$ rvm install 1.9.3
Either way, make sure you run
$ rvm --default use 1.9.3
Note that you may have to install XCode and XCode Command-Line Tools before all of this. Note also that you probably shouldn't use sudo... just have it install ruby for your user.
Trying to install and use ruby 1.9.2 on my server. Running Ubuntu 11.10.
$ rvm use 1.9.2
Using /usr/share/ruby-rvm/gems/ruby-1.9.2-p180
$ ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]
Wait...what?
Below are the steps for a fresh installation if you need it at any time:
bash -sk stable < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
source ~/.bash_profile
source /etc/profile.d/rvm.sh
rvm requirements #Lets you know the system dependencies and if you need to install any other libraries
rvm install 1.9.2-p290
rvm use 1.9.2 --default
rvm gemset create demo
rvm demo#1.9.2
then install rails
gem install rails -v=3.0.4
If at any time u mess up your rvm you can remove it using rvm implode or rm -rf ~/.rvm
You are using buggy version of RVM, use this instructions to install proper version: https://stackoverflow.com/a/9056395/497756
I have recently installed RVM on a fresh install of Ubuntu 11.10 and can not work out how to start using a particular ruby version.
I have installed Ruby 1.8.7 and 1.9.2, and they show up in the list fine:
$ rvm list
rvm rubies
ruby-1.8.7-p352 [ i386 ]
ruby-1.9.2-p290 [ i386 ]
When I try to use the "use" command, everything seems fine:
$ rvm use 1.9.2
Using /usr/share/ruby-rvm/gems/ruby-1.9.2-p290
Running /usr/share/ruby-rvm/hooks/after_use
But then when I test the current ruby version, I get the usual Ubuntu 11.10 message you get when you don't have RVM at all:
$ ruby -v
The program 'ruby' can be found in the following packages:
* ruby1.8
* ruby1.9.1
Try: sudo apt-get install <selected package>
What am I doing wrong? Did I miss out a step in the RVM installation or something?
EDIT*
Answers to some comments:
$ which ruby
#returns nothing at all.
$ which rvm
/usr/bin/rvm
$ rvm -v
rvm 1.6.9 by Wayne E. Seguin (wayneeseguin#gmail.com) [https://rvm.beginrescueend.com/]
$ echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
RVM 1.6.9 is very old now. Did you install it through some package manager? If so, get rid of it and run the following in your bash shell:
curl -L https://get.rvm.io | bash -s stable
Then, place [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" in ~/.profile OR ~/.bash_profile OR ~/.bashrc
You should then be able to run type rvm | head -n 1 and it should say "rvm is a function".
Then you should be able to install rubies and use one of them. Be sure to use --default for that Ruby to remain the default even after you end your terminal session. E.g. rvm use ruby-1.9.2-p290 --default
Have you added the following line to your .bash_profile,
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
as the installation page for rvm says?
Like tass suggested you obviously have a different rvm directory then $HOME/.rvm so
[[ -s "/usr/share/ruby-rvm/scripts/rvm" ]] && . "/usr/share/ruby-rvm/scripts/rvm"
is probably what you would to use instead
I know this thread is zombie-old, but in your terminal client's preferences, checking 'run command as login shell' solved it for me. RVM generally puts that line in your ~/.bash_profile for you.
I'm running Ruby 1.9.1p243 on CentOS, and I decided to install rvm to handle upgrading to 1.9.2 or downgrading to 1.8.7 (whichever turns out to work better for rails3).
I followed the instructions here: http://rvm.beginrescueend.com/rvm/install/ and everything installed correctly. I was able to compile and install Ruby 1.8.7, 1.9.1, and 1.9.2.
However, if I try to actually switch to one of the rvm installed Rubies, with rvm use 1.8.7, for example, nothing works. My system still uses the Ruby I have installed in /usr/local/bin/ruby.
An example of the output I get:
$ rvm use 1.8.7
$ ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux]
$ which ruby
/usr/local/bin/ruby
$ rvm use 1.9.2
$ ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux]
$ which ruby
/usr/local/bin/ruby
I have no idea why this is happening, and I can't seem to find anything online about the issue either. Any help would be appreciated.
Just came across the same problem.
Instead of appending the following script to ~/.bash_profile, append it to ~/.bashrc:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
And then restart the terminal.
Typically rvm support is easiest via IRC (#rvm on freenode) - in this particular case, what does running "type rvm | head -n1" show? it should show "rvm is a function". If not, that means the line to source rvm isn't being run correctly and hence switching doesn't work. Typically this means you either have a return in your ~/.bashrc or you missed adding the line to source rvm.
Your install it as root account.
Try this in shell:
[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm"
before rvm switch operation. I add this line in my profile file and now all is ok.
Can be a problem of Terminal and
you should try to close your Terminal's window
and to open new one. :)
Try again to see if it has changed...
I've been struggling with setting default rvm ruby to no avail, until I've tried this:
sudo bash -l -c 'rvm alias create default ruby-1.9.3-p392'
"sudo" is for writing into /usr/local/rvm/config/alias (in my example it would contain "default=ruby-1.9.3-p392")
"bash -l" is to make sure it runs all the scripts (/etc/profile, /etc/bash.bashrc, etc..) of login shell