Today I learned that Ubuntu is bundled with Ruby 1.8.7. I want 1.9.2, but getting Ruby 1.9.2 working has been frustrating.
First, note that Ruby 1.9.2 is already installed on my system.
Here's what's happening:
$ ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
$ rvm list
rvm rubies
=* ruby-1.9.2-p290 [ x86_64 ]
ruby-1.9.3-p0 [ x86_64 ]
$ printenv PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
$ which ruby
/usr/bin/ruby
$ which rvm
/usr/bin/rvm
RVM hasn't initialized correctly. Your path should show RVM's managed directories first.
Have you added the RVM initializer to your .bash_profile or .bashrc, and have you restarted your shell session or logged out then back in?
Have you followed the installation and troubleshooting directions at http://rvm.beginrescueend.com/rvm/install ?
Please append the output of rvm info to your question.
Normally RVM would install inside your ~/.rvmrc directory for a single-user sandbox. Because it is at /usr/bin/rvm that tells me you installed it as root or did a sudo when you installed it. I highly recommend not bothering with multi-user RVM unless you have a really good reason, and instead use the single-user install.
Related
I want to install the compass html5 boilerplate gem. When I try to install it I get the following error.
$ sudo gem install html5-boilerplate
ERROR: Error installing html5-boilerplate:
compass-h5bp requires Ruby version ~> 2.0.
Then when I check my ruby version it says:
$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
But I used RVM before so I thought I could just change version but when I check it says I'm using ruby-2.2.0 already.
$ rvm list
rvm rubies
=* ruby-2.2.0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
I think I must be missing something obhvious, it's been a while since I've worked with Ruby and RVM.
Update 1
I ran the below commands as suggested by #tadman and it does seem the wrong path is being used.
~:$ cd ~/.rvm/bin
bin:$ ls
ruby-rvm-env rvm rvm-auto-ruby rvm-exec rvm-prompt rvm-shebang-ruby rvm-shell rvm-smile rvmsudo
bin:$ which ruby
/usr/bin/ruby
UPDATE 2
After correcting the path in my .bash_profile the ruby version seems correct but I'm still getting the same error when trying to install the html5-boilerplate gem??
$ sudo gem install html5-boilerplate
ERROR: Error installing html5-boilerplate:
compass-h5bp requires Ruby version ~> 2.0.
$ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
$ rvm list
rvm rubies
=* ruby-2.2.0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
$ compass -v
Compass 1.0.3 (Polaris)
Copyright (c) 2008-2015 Chris Eppstein
Released under the MIT License.
Compass is charityware.
Please make a tax deductable donation for a worthy cause: http://umdf.org/compass
Also i have the compass gem installed on both Ruby 1.9.1 and RVM's ruby 2.2.0. Could this have something to do with it?
$ pwd
/var/lib/gems/1.9.1/gems/compass-1.0.3
$ cd /home/ross/.rvm/gems/ruby-2.2.0/gems/compass-1.0.3
$ pwd
/home/ross/.rvm/gems/ruby-2.2.0/gems/compass-1.0.3
Is there a way to check which ruby version compass is using?
Having RVM and having RVM installed correctly are two different things. The most common cause of a mismatch like this is that your system Ruby has priority in your PATH.
In a POSIX shell, which ruby will tell you which one is getting executed. It is probably the wrong one.
RVM does its magic by manipulating which Ruby shows up in the RVM bin path, often ~/.rvm/bin or something similar. To get it to work correctly you'll need to ensure that path is first in your $PATH.
You may want to try reinstalling the RVM stub, or check that it's correctly loaded into your environment.
I have RVM installed on a machine under a single users account on an Ubuntu 10.04 machine, and I want to give the other users of this machine access to that same install.
Is there a way to do this?
In case of binary rubies it should be possible to just move RVM.
Check not movable rubies
You can find if there are any not movable rubies with
rvm all --verbose do rvm config-get configure_args | grep -v -- '--enable-load-relative'
In my case it is (just few):
jruby-1.7.3: jruby 1.7.3 (1.9.3p385) 2013-02-21 dac429b on OpenJDK 64-Bit Server VM 1.7.0_21-b02 [linux-amd64]
rbx-head: rubinius 2.0.0.rc1 (1.8.7 bed7e913 yyyy-mm-dd JI) [x86_64-unknown-linux-gnu]
ruby-1.8.7-p374: ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
'--prefix=/home/mpapis/.rvm/rubies/ruby-1.8.7-p374' '--disable-install-doc' '--enable-shared' 'CC=ccache gcc' 'CFLAGS=-O3 -O2 -fno-tree-dce -fno-optimize-sibling-calls'
ruby-1.9.3-p448: ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]
'--prefix=/home/mpapis/.rvm/rubies/ruby-1.9.3-p448' '--disable-install-doc' '--enable-shared' 'CC=ccache gcc'
ruby-2.0.0-p247: ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
For those rubies that have flags you need to either remove them or reinstall after RVM is moved, in this case this are: 1.8.7 and 1.9.3.
Moving RVM
It should be as easy as:
sudo mv ~/.rvm /usr/local/rvm
__rvm_switch /usr/local/rvm
Simulate installation (to generate shell initialization entries for system installation:
rvmsudo rvm get stable --auto-dotfiles
Now for every user that should be able to use RVM add them to rvm group:
rvmsudo rvm group add rvm $USER
Repeat it for every user replacing $USER with the user name.
Reinstalling not movable rubies
For rubies found in first step run:
rvm reinstall ruby-1.8.7-p374,ruby-1.9.3-p448
Cleaning
The user account that installed RVM in first place will have old initialization code, you can find it with:
grep -n rvm ~/.profile ~/.bashrc ~/.bash_profile ~/.bash_login ~/.zshenv ~/.zprofile ~/.zshrc ~/.zlogin
This will show the lines that contain RVM, open this files in your favorite editor and remove them.
I seriously doubt it's worth trying to convert a single user's installation to multiple-user.
During the installation of a unique Ruby, its path is compiled into components. That will be remembered and would have to be changed.
I think it would be much easier to install using the multi-user method and reload the needed gems. It might take a couple hours if you have multiple Rubies and a lot of gems, but that's a lot better than weeks of debugging weird errors.
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.
If I run:
rvm system
ruby -v
I get:
ruby-192...
I want the system version that is Ruby 1.8.7.
Ruby 1.9.2 was installed using RVM. I still can see Ruby 1.8.7 if I run /usr/bin/ruby -v.
rvm info
system:
system:
uname: "Darwin MacML.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)"
zsh: "/bin/zsh => zsh 4.3.11 (i386-apple-darwin11.0)"
rvm:
version: "rvm 1.10.0 by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.beginrescueend.com/]"
homes:
gem: "not set"
ruby: "not set"
binaries:
ruby: "/usr/local/bin/ruby"
irb: "/usr/local/bin/irb"
gem: "/usr/local/bin/gem"
rake: "/usr/local/bin/rake"
environment:
PATH: "/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/Users/ML/.rvm/bin"
GEM_HOME: ""
GEM_PATH: ""
MY_RUBY_HOME: ""
IRBRC: ""
RUBYOPT: ""
gemset: ""
First, use rvm info and make sure the values reported are sane and what you expect.
As of this moment, RVM is at version 1.10.0. If rvm -v shows a lower version number, run rvm get head;rvm reload to update to the current version. That step alone can fix all sorts of issues.
To switch from a RVM controlled Ruby back to the version installed in your Mac by Apple, use:
rvm system
That should allow you to do:
which ruby
and get:
/usr/bin/ruby
or:
ruby -v
and get something like:
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin10.0]
To return to a RVM controlled Ruby, use: rvm 1.9.2 or rvm default if you have set up a default Ruby.
If you haven't set up a default Ruby, I recommend you do so, using: rvm 1.9.2 --default, substituting whatever version of Ruby you want as your default.
You do NOT have to install a version of 1.8.7 under RVM's control if you don't want to, however, if you intend to modify the 1.8.7 owned by the system by adding or changing gems do so carefully. That version was installed for Apple's use and you are piggybacking on it and changes could affect the use of certain apps or future apps installed by Apple.
If you need to add gems or tweak 1.8.7, I'd recommend using RVM's rvm install 1.8.7 into your sandbox, and go from there. At that point you can eschew using the system version of Ruby 1.8.7, and leave it alone for Apple's apps.
If all you want to do is install MacVIM, you can accomplish what you want, which is to tell the system that the RVM versions are NOT installed, by temporarily tweaking your PATH variable to NOT include the RVM controlled Rubies in your ~/.rvm directory.
You can do that by editing PATH, or by temporarily modifying your ~/.bash_profile or ~/.bashrc, whichever has the RVM initialization in it. Open a new shell, run your install steps, then revert the file.
There are many ways to get where you want to go.
Maybe you should try: rvm use system?! Or rvm use system --default to use system Ruby every time.
First you need to install 1.8.7:
rvm install 1.8.7
Then you need to tell RVM you want to use this one as the default:
rvm use 1.8.7 --default
I'm not sure why the system is not working right for you, but installing 1.8.7 and using it should resolve the compilation error for macvim. Instead of "rvm system", run
rvm install 1.8.7
rvm use 1.8.7
That should resolve it.
The problem were these 2 lines below on my .profile
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
I commented both and the path to the system ruby went back to normal. the Tin Man tip was crucial to find what the problem was.
I had one ruby version in /usr/local/bin/ruby and another in /usr/bin/ruby
After I commented the lines mysql stopped working by I reinstalled with brew and everything seems to be working
I get an "rvm: command not found error" on rvm gemdir, but only when I'm using one of the rvm ruby installations. I get the same result with 1.9.2 and 1.8.7 (the only ones I've tried):
$ rvm install 1.8.7
...
Installation of rubygems completed successfully.
...
Install of ruby-1.8.7-p334 - #complete
# works ok using system ruby
$ rvm gemdir
/Library/Ruby/Gems/1.8
$ rvm use 1.8.7
Using /Users/aneil/.rvm/gems/ruby-1.8.7-p334
#
# HERE IS THE ERROR:
#
$ rvm gemdir
/Users/aneil/.rvm/scripts/gemsets: line 786: rvm: command not found
/Users/aneil/.rvm/gems/ruby-1.8.7-p334
$ rvm use system
Now using system ruby.
$ rvm gemdir
/Library/Ruby/Gems/1.8
Any ideas what's going on here? Should I be concerned?
Thanks.
try running
rvm get latest
from shell. addressed the issue for me.