This problem probably has an obvious answer to anyone who has used Ruby on linux for a long time, but I can't really get a good answer via Google.
I'm trying to check out the Rails 5 beta, which requires Ruby 2.2.2 or greater. I've installed the RVM (Ruby Version Manager) and set my ruby version to 2.2.3. Running rvm list in the terminal results in the following output:
rvm rubies
=* ruby-2.2.3 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Okay, great. I have Ruby 2.2.3 installed. Let's try bundle update:
Installing rack 2.0.0.alpha (was 1.6.4)
Gem::InstallError: rack requires Ruby version >= 2.2.2.
Okay, that's weird. What version of ruby do I have? Running ruby -v gives me this:
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
So... do I have 2.2.3 or not? What gives?
Since you are using bundle, I would suggest you to check your Gemfile for ruby version. You can also test it with bundle exec ruby -v
Also try:
rvm use ruby-2.2.3
bundle exec ruby -v
Maybe by setting the default Ruby version on rvm to the one you have (ruby-2.2.3) solves the problem, by doing rvm --default use ruby-2.2.3. Then reload the bash and execute ruby -v to check if the default version of Ruby was changed properly and then try again to execute the bundle install command.
If you don't know zsh and oh-my-zsh, I highly recommend for this kind of things. You could configure the terminal in order to show you the current version of Ruby and Rails that you're using every moment. Check it here: http://ohmyz.sh/
In addition to doing rvm use --default 2.2.3 or rvm use 2.2.3 make sure that you don't have the ruby package from apt (or whatever package manager) still installed. For some reason, that ruby package could take precedence over an RVM Ruby.
Also, try doing rvm uninstall 2.1.5 to force your system to default to 2.2.3... You can always reinstall 2.1.5 later and, if this issue persists, 2.2.3 should stick as your default.
Related
I"m using Ubuntu and RVM. I've run the command
rvm use 2.1.2
Running
ruby -v
gives me the 2.1.2 version.
When I start rails I get the following error
Your Ruby version is 2.3.1, but your Gemfile specified 2.1.2
But RVM doesn't even have 2.3.1 installed.
You may have apt installed ruby. For example, when I run apt show ruby, on my system, I get this
$ apt show ruby
Package: ruby
Version: 1:2.3.0+1
Priority: optional
Section: interpreters
Source: ruby-defaults
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss#lists.ubuntu.com>
...
Clearly, the ruby version is 2.3.x here. So I suggest you apt remove ruby first. If that doesn't solve the problem, it is possible that there is a problem with your $PATH environment variable.
ruby -v gives you the ruby version installed on your system, not the current ruby version used by RVM.
To see which ruby version is currently used by RVM, use rvm list. Make sure it's using ruby version 2.1.2 by running rvm use ruby-2.1.2
From your question, it seems Rails is using your system ruby instead of RVM ruby.
I have to upgrade from ruby 1.8.7 to ruby 1.9.3; I'm trying to install refinery cms and it uses truncate_html gem, which depends on ruby (>= 1.9). I've installed ruby 1.9.3-p374 without removing ruby 1.8.7.
I've used the command rvm --default use 1.9.3 and it issued the result
Using /usr/share/ruby-rvm/gems/ruby-1.9.3-p374
but when i type ruby -v it was again 1.8.7.
How can I upgrade to ruby 1.9.3?
You are using RVM Ubuntu package which is broken, use this instructions to update https://stackoverflow.com/a/9056395/497756
Are you using a .rvmrc file for your project? If so, it might be selecting a specific Ruby over your default.
Open ./.rvmrc if it exists and remove (as necessary) any rvm use... references.
Try
ruby1.9.1 <filename.rb>
I'm on Linux Ubuntu 12.04, and I first installed Ruby 1.9.2.
After I tried installing rvm to use Octopress, ruby --version in bash results in ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
How can I use RVM with ruby 1.9.2?
I don't really understand what RVM is all about...
The 1.9.2 version you installed first is not accessible from rvm.
While working with rvm, only the list of rubies installed through rvm is served. The previously installed versions of ruby - while still present in the filesystem - are not included.
With the steps you have done so far, you have a 1.9.2 version installed in one location, and a 1.8.7 version installed as part of rvm.
Install 1.9,2 version by running the rvm install 1.9.2 command. After that, when you run the rvm list command, you should see an output similar to the following:
$ rvm list
rvm rubies
ruby-1.8.7-p358 [ i686 ]
=* ruby-1.9.2-p320 [ x86_64 ]
# => - current
# =* - current && default
# * - default
You can switch between different versions of ruby managed by rvm with the rvm use 1.8.7 / rvm use 1.9.2 commands.
Here's a short blogpost with a good intro to rvm: Get started right with RVM
RVM is a version manager which enables you to decide which of multiple installed Ruby versions you want to use in your current shell session. RVM does this by providing a shell function named rvm which can be used to switch between versions in the current session. This changes environment variables, especially the GEM_HOME and PATH, to match the currently selected Ruby installation.
Every installed Ruby version can be selected by a specific identifier string. If you had a system-wide Ruby installation already before you installed RVM, that one should be referenced by the string system. The newly installed version in your case should be called 1.9.2.
To make RVM work as intended, it is necessary to load the rvm shell function into your shell. How to do this is described in the RVM Installation Documentation in section 2 - "Load RVM into your shell sessions as a function".
You can see if the shell function is correctly loaded when the command type rvm | head -n1 responds with:
rvm is a shell function
If not correctly loaded it will tell you something like this:
rvm is /home/someone/.rvm/bin/rvm
If you finally have it working you can switch your active Ruby version with commands like rvm 1.9.2 or rvm system. You can get a list of all Ruby versions and their identifier strings recognized by RVM by the command rvm list.
You can also specify which Ruby version shall be enabled in all new shell sessions from the beginning by issuing the following command once:
rvm --default 1.9.2
Perhaps you have not yet switched to the ruby version with:
rvm use 1.9.2 (assuming you did rvm install 1.9.2)
for a more general explanation I gave an answer here which might help.
Sounds strange but I cannot tell which ruby version is installed. If I do
rvm rubies
I get
ruby-1.9.2-p180 [ i686 ]
but with
ruby -v
I get
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
When trying to
rvm upgrade 1.8.7-p302 1.9.2-p180
I get an error
ERROR: Ruby 'ruby-1.8.7-p302' is not installed - please install it first.
ERROR: Error migrating gems.
So, which one is it? 1.8.7-p302 or 1.9.2-p180 ???
Please help me out here! Thanks
You get 1.8.7 from the installed version of your system. Use rvm use --default 1.9.2 in order to set the Ruby installed via rvm as default.
RVM basically changes your $PATH variable to point to a different Ruby version than the one installed on your system.
Please also make sure that you have done steps 2 and 3 of the installation guide and confirmed that RVM is correctly set up.
You might have 1.8.7 because you did sudo apt-get install ruby or something like that, and then later ran rvm install 1.9.2. Is that the case?
The answer is both as mentioned by other posters. As a recommendation you should uninstall the ruby packages that come with the system if you choose to manage ruby version using rvm.
I just upgraded to rails 3 but was running ruby 1.9.1 prior to the upgrade. Rails 3 doesn't support Ruby 1.9.1. How can I downgrade to ruby 1.8.7?
This will downgrade from your current version to 1.8.7:
gem update --system 1.8.7
install rvm, this will allow you to run multiple versions of ruby and switch between them at will: rvm
As others have mentioned, its hard to come up with exact solution, in general to downgrade or switch versions for a user:
Install Ruby 1.8.7 (or locate it on your system if you have it already)
Edit your .bash_profile or .bashrc file to update your $PATH so that the 1.8.7 executable is found first. Something like this:
export RUBY_187_HOME='/path/to/1.8.7'
export PATH=$RUBY_187_HOME/bin:$PATH
This is a little similar to what RVM does and it works.
To test, try
$ which ruby
$ /path/to/1.8.7/bin/ruby