RVM and Ruby version not working as expected - ruby

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.

Related

Cannot install jekyll as it complaints: 'requires Ruby version >= 2.3.0'

I have only one ruby version installed:
$ rvm list
=* ruby-2.5.7 [ x86_64 ]
# => - current
# =* - current && default
# * - default
But any time I install jekyll or bundler I got complain of an older version.
$ sudo gem install bundler
ERROR: Error installing bundler:
bundler requires Ruby version >= 2.3.0.
Unable to find the reason.
Operating system: CentOS
When using RVM as your Ruby manager you do not (and should not) use sudo. Sudo runs everything under the root account. But RVM is installed under your own user account, and therefore sudo is not needed, and will in fact circumvent RVM if used.
So, just drop the sudo part, and if RVM is installed properly, everything should start working correctly:
gem install bundler # <- no sudo needed
I bit late, but I had the same problem and couldn't find an answer documented anywhere.
The problem is that sudo uses a different version of ruby than what rvm has set. You can see this by comparing ruby -v and sudo ruby -v.
To solve this, try rvmsudo gem install bundler. This causes sudo to use the version of ruby that rvm expects.
Read more here: https://rvm.io/integration/sudo

RVM ruby version 2.2.1, Actual ruby version 1.8.7

I am trying to install Jekyll in a VM for my web course and it required ruby >= 2.0.0.
I've gone through installing RVM and using this to install the desired version of ruby, but I then get the following:
vagrant#precise32:~/.rvm/bin$ bash rvm list
rvm rubies
ruby-2.1.1 [ i686 ]
=* ruby-2.2.1 [ i686 ]
 # => - current
 # =* - current && default
 # * - default
vagrant#precise32:~/.rvm/bin$ ruby -v
ruby 1.8.7 (2011-06-30
patchlevel 352) [i686-linux]
vagrant#precise32:~/.rvm/bin$ sudo gem
install jekyll ERROR: Error installing jekyll:jekyll requires Ruby version >= 2.0.0.
vagrant#precise32:~/.rvm/bin
I don't understand why it still thinks it is using version 1.8.7, as it confirms that it has installed 2.2.1.
I have done the following:
Use sudo chown to change ownership of the .gnupg folder recursively to vagrant (my system user) as defined here.
Install RVM following the instructions here.
Installed the version (2.2.1) of ruby using these instructions (https://rvm.io/rubies/installing).
Tried to install Jekyll using sudo gem install jekyll, but I get an error saying that I need ruby version 2.0 or higher.
I'm not a developer, this is an introductory web development course. Also please excuse the corrupt link, I can't post more than 2.
Update: I think I might need to do something as described here: How do I change my Ruby version using RVM?.
Also - although I installed RVM, I originally installed it using sudo apt-get which corrupted it. I uninstalled that, and ran the most recent install with curl. To use it I have to navigate to the directory and use "bash rvm list"
Add following two lines:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
to your $HOME/.profile file and restart a shell.
It seems your machine is using Its own instead by RVM.
1: rvm list # Listing install rubies will you get versions of ruby which is installed by RVM
2: rvm use < ruby-version > # for instances ruby-1.9.3-p125
3: bundle install
4: Tried to install Jekyll using sudo gem install jekyll, but I get an
error saying that I need ruby version 2.0 or higher.
For that you could try Installing Jekyll on Ubuntu 14.04
Hope this help you !!!

Need to remove ruby to install cocoapods

I'm trying to install cocaopods on my Mac Yosemite system. However, when I type in this command:
$ sudo gem install cocoapods
It returns this error:
ERROR: Error installing cocoapods:
i18n requires Ruby version >= 1.9.3.
Typing which ruby, returns:
/Users/myname/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
typing rvm rubies gives this message:
rvm rubies
ruby-1.8.7-p334 [ x86_64 ]
=> ruby-1.9.2-p180 [ x86_64 ]
However, typing /usr/bin/ruby --version gives this message:
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
I'm thinking if I can uninstall the ruby that's in my home directory, the cocoapods install will find the more recent ruby version. However, I'm not not sure exactly how to do that and/or what impact it would have. Any suggestions?
Looks like you have rvm installed when you don't want to. You can remove it entirely with rvm implode. Then when you open a new shell which -a ruby should just show /usr/bin/ruby

Ruby version and rvm out of sync, Ruby interpreter version not changing

Because of a legacy system, I need to use Ruby v1.8.7-p374. I've been using RVM to use that version of Ruby and all seemed to work well, until something changed.
Now my system will not use the Ruby version that I'm specifying with RVM. Is there a way to switch between the Ruby versions manually?
Related question: "Can't change Ruby Version using RVM"
Here are some relevant pieces of information:
$ rvm --default use ruby-1.8.7-p374
Using /Users/wroberts/.rvm/gems/ruby-1.8.7-p374
$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin13]
$ echo $PATH
/Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin:/Users/wroberts/.rvm/gems/ruby-1.8.7-p374#global/bin:/Users/wroberts/.rvm/rubies/ruby-1.8.7-p374/bin:/Users/wroberts/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/ant/bin:/usr/local/mysql/bin:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin:/usr/local/apache-maven/apache-maven-3.2.3/bin:/usr/bin/chromedriver/bin:/Users/wroberts/dev/tools/flex:/usr/local/bin:/usr/bin:/usr/sbin
$ rvm list
rvm rubies
ruby-1.8.7-head [ i686 ]
=* ruby-1.8.7-p374 [ i686 ]
# => - current
# =* - current && default
# * - default
$ which ruby
/Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin/ruby
$ ls /Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin/ruby
/Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin/ruby
$ rvm info
RVM version 1.26.4 (master) is installed yet 1.26.4 (latest) is loaded.
Please do one of the following:
* 'rvm reload'
* open a new shell
* 'echo rvm_auto_reload_flag=1 >> ~/.rvmrc' # for auto reload with msg.
* 'echo rvm_auto_reload_flag=2 >> ~/.rvmrc' # for silent auto reload.
Even more issues now:
$ rvm install 1.8.7 --without-tcl --without-tk
Warning! PATH is not properly set up, '/Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-1.8.7-p374'.
Warning! Requested ruby installation which requires another ruby available - installing ruby-1.8.7-p374 first.
Checking requirements for osx.
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions
/Current/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 28: /usr/local/Library/brew.rb: Undefined error: 0
ERROR: '/bin' is not writable - it is required for Homebrew, try 'brew doctor' to fix it!
Requirements installation failed with status: 1.
To proceed rvm requires a ruby-1.8.7-p374 compatible ruby is installed.
We attempted to install it automatically but it failed with status 1.
Please install it manually (or a compatible alternative) to proceed.
IT IS WORKING -- my workaround, and one more question
so I did the rvm implode, which (I think) resulted in ruby not being in the System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby.
So everytime I tried to install 1.8.7 --without-tcl --without-tk something was wrong with my brew file.
A FEW FINAL QUESTIONS:
I checked the brew file and at the top it was using
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0
and I changed it to
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
and now brew worked, I was able to install 1.8.7 and do rvm --default use ruby-1.8.7-p374 and my gems install etc.
First question, is this hacky solution a major issue for me, not a big deal, or unknown territory due to sheer stupidity of the problem?
Second question, everytime I open a new bash shell ruby -v gives me the (I believe) system version of ruby:
$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin13]
$ which ruby
/usr/bin/ruby
but then I set the default rvm and would like this to happen automatically,
$ rvm --default use ruby-1.8.7-p374
Warning! PATH is not properly set up, '/Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-1.8.7-p374'.
Using /Users/wroberts/.rvm/gems/ruby-1.8.7-p374
$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin13.4.
$ which ruby
/Users/wroberts/.rvm/rubies/ruby-1.8.7-p374/bin/ruby
It says my path is not properly set up, but if you check the top of this post, /Users/wroberts/.rvm/gems/ruby-1.8.7-p374/bin IS at the first place, how can this be fixed?
RVM is telling you that it doesn't like the configuration of your shell. So try running
rvm get stable --auto-dotfiles
as it suggests. RVM needs to be the last thing included in your shell config otherwise its functionality can be affected by shell commands loaded after it.
If you are using homebrew, I'd do an update and doctor.
Do:
rvm implode
install rvm
again. This should fix the issue.

rvm gemdir gives error ~/.rvm/scripts/gemsets: line 786: rvm command not found

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.

Resources