I installed ruby via
apt-get install ruby1.9.1 rubygems
However, when I run ruby --version I see
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
Have I missed something? When I try to run a gem which requires 1.9+ it fails and asks me to upgrade.
The package ruby1.9.1 will give you an executable called ruby1.9.1, which you should use instead of ruby.
You can set ruby1.9.1 as default ruby version using following command
update-alternatives --set ruby /usr/bin/ruby1.9.1
You may find out about available alternatives using following
update-alternatives --query ruby
In this way you can set the default ruby version
$ rvm --default use 1.9.2
$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
Related
So, I just updated Ruby version on a CentOS 7 box, to allow for the use of OpenSSL, using this guide:
https://www.server-world.info/en/note?os=CentOS_7&p=ruby23
However, the version is now set to 2.3.8 as per:
$ ruby -v
ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-linux]
and:
$ which ruby
/opt/rh/rh-ruby23/root/usr/bin/ruby
$ which gem
/opt/rh/rh-ruby23/root/usr/bin/gem
BUT, gem throws the same error as before hand:
$ sudo gem install openssl
ERROR: Error installing openssl:
openssl requires Ruby version >= 2.3.0.
Any ideas?
Try installing gems without sudo. I did such test locally
$ ruby -v
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
$ sudo ruby -v
sudo: ruby: command not found
Probably your superuser env is not using the same ruby version as your current user's env.
When I try to run a ruby command in terminal I get an error:
Ruby >= 2.1.9 required to run app (You have 2.0.0)
When I try
brew upgrade ruby
I get
Error: ruby 2.3.1 already installed
Previously I tried installing ruby with rvm
curl -sSL https://get.rvm.io | bash -s stable --ruby
Maybe I have two different versions of ruby running?
How can I get my system to use the latest version of ruby?
EDIT: Definitely two versions installed
/usr/local/bin/ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14]
ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
My $PATH seems correct?
-bash: /usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin: No such file or directory
EDIT2 specifying the full path to the correct version of ruby:
/usr/local/bin/ruby app.rb
/usr/local/bin/ruby: No such file or directory -- app (LoadError)
In the simplest cases, you can just specify the fully-qualified PATH to your Homebrew-installed Ruby. For example:
/usr/local/bin/ruby /path/to/foo.rb
However, if you need to require gems or libraries, you need to step up your game with a Ruby version manager such as chruby, rvm, or rbenv. You should never replace the system ruby, and managing all the environments variables, gems, and so forth that Ruby needs without a version manager is outside the scope of a reasonable Stack Overflow question.
You have installed the homebrew version 2.3.1 of Ruby, but you are not using it because you haven't set your PATH correctly.
Try using the one homebrew installed for you by adding /usr/local/bin to the start of you PATH, or by running:
/usr/local/bin/ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
I guess if you use the Apple-supplied Ruby in /usr/bin you will get:
/usr/bin/ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
You should uninstall ruby from brew and just use rvm.
If you have multiple version installed than you can use rvm to make ruby 2.3.1 your default: rvm --default use 2.1.1
I have installed ruby 1.9.3 in my Ubuntu 12.04 machine following the instructions in https://github.com/postmodern/ruby-install and executing the following command:
sudo ruby-install ruby 1.9.3
I was assuming this would link from my /usr/bin or somewhere else visible from my path ruby or gem, but it doesn't. When I try for example: gem install bundler, I get:
sudo: gem: command not found
It also can't find ruby when I try ruby -v.
If I install with sudo apt-get install ruby1.9.3, I'm able to execute both ruby and gem:
$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
$ gem -v
1.8.11
I was expecting from ruby-install the same output I got from apt-get. Am I looking in the wrong place? How do I run ruby and gem after installing with ruby-install?
I know there are other installers for ruby like rvm and rbenv, but I'm following some installations instructions and they clearly instruct to use ruby-install.
Thanks in advance!
OK, found the answer.
After running
sudo ruby-install ruby 1.9.3
the last line from the log is:
>>> Successfully installed ruby 1.9.3-p547 into /opt/rubies/ruby-1.9.3-p547
Which I have no excuse for not paying attention to since it's in bold colourfull letters.
Erm, anyway, adding /opt/rubies/ruby-1.9.3-p547 to the PATH makes ruby and gem work.
export PATH=$PATH:/opt/rubies/ruby-1.9.3-p547/bin
How can I use rvm to install a specific version of Ruby, e.g. 1.9.3p327 instead of the current 1.9.3p194 that I have.
All the references and document are about the major version, e.g. rvm install 1.9.3 but don't mention the 'p' minor version numbers.
I tried
$ rvm install 1.9.3p327
Unknown ruby interpreter version: '1.9.3p327'.
Could not detect ruby version/name for installation, please be more specific.
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
$ rvm install '1.9.3p327'
Unknown ruby interpreter version: '1.9.3p327'.
Could not detect ruby version/name for installation, please be more specific.
Turned out to be a dash ! $ rvm install 1.9.3-p327
rvm install 1.9.3p327 should work without single quotes.
EDIT: The following option is now deprecated.
Alternatly, to install a patch specific level you could use the -l option. For example
rvm install 1.9.3 -l 327
I've got Xcode 3.2.1
I've installed Git and RVM
I've installed Ruby 1.9.2, it's installed 100%
I run ruby -v but instead of seeing
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
I see
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
I don't see what I could be going wrong
Try
rvm 1.9.2
Or
rvm --default 1.9.2
It is possible to use a .rvmrc to do that for the directory you cd into as well.
Have you selected the version of ruby you want to use with rvm? As in this? Note the "rvm 1.9.2" line hidden away after the rvm and ruby installs.
Type in 'rvm 1.9.2' and then type 'ruby -v'... did you do that? It looks like the Ruby 1.8.7 on your machine is the one included with OS X.