ruby -v different from rvm - ruby

Mohameds-MacBook-Pro-2:~ mmahalwy$ rvm list
rvm rubies
=* ruby-2.1.1 [ missing bin/ruby ]
# => - current
# =* - current && default
# * - default
Mohameds-MacBook-Pro-2:~ mmahalwy$ ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
I need to get the system to use the RVM ruby and not the preinstalled ruby that ships with Mavericks.
I do have the [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" at end of .bashrc file
I also get this error when i start a new terminal session:
bash: /etc/profile.d/rvm.sh: No such file or directory

You have not mentioned what you have tried so far. The following commands typically works for me after install RVM.
Assuming you have installed rvm using this
curl -sSL https://get.rvm.io | bash -s stable
Then you just have to install ruby and mark it as default ruby for your system.
rvm install 2.1.1
rvm use 2.1.1 --default
I have a Mac and I have done this many times and yet to face an issue.

Related

Ubuntu ruby version keeps changing even after specifying default version in rvm

I want to use ruby 2.3.4 for my rails application which I have installed using rvm on Ubuntu 16.04.
after using command rvm list.
rvm rubies
=* ruby-2.3.4 [ x86_64 ]
# => - current
# =* - current && default
# * - default
but when i use ruby -v I get.
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]
so I used rvm --default use 2.3.4.
which does change the version to 2.3.4 when I check using ruby -v but when I restart the terminal or system it changes back to 2.5.0
I want to know how to include 2.5.0 into rvm or remove it.
Check that .bash_profile contains below lines:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Check .bashrc, .zshrc, .mkshrc file contains below lines at end of file:
export PATH="$PATH:$HOME/.rvm/bin"
if not then,
First Run below command then follow link to install rvm:
rm -rf ~/.rvm
RVM Install

System and rvm Ruby versions are different

I installed rvm and used it to install Ruby. According to rvm my current and default version is 2.1.0 however ruby -v gives me two options and neither is the version listed as the default by rvm. What am I missing?
Thanks in advance!
foo#ua41f725e9ecd517ff31d:~$ rvm list
rvm rubies
=* ruby-2.1.0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
foo#ua41f725e9ecd517ff31d:~$ ruby -v
The program 'ruby' can be found in the following packages:
* ruby1.8
* ruby1.9.1
Try: sudo apt-get install <selected package>
You need to make sure that the place where rvm installs the ruby binaries is in your $PATH.
Try adding the following to your .bashrc, .bash_profile, or .zshrc or whatever shell you are using.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
The Ruby installed by rvm isn't in your PATH. That message you saw at the bottom was the system telling you it couldn't find any Ruby version. Be sure that rvm is setting your PATH up correctly.

Installing Ruby 1.9.2 on Ubuntu via RVM

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

Ruby 1.8.7 upgrade to ruby 1.9.2

I am going through this tutorial, but I already had Ruby 1.8.7 installed. I need to have 1.9.2/1.9.3 version.
I started to use RVM.
$ rvm list rubies
rvm rubies
ruby-1.8.7-p358 [ x86_64 ]
ruby-1.9.2-p318 [ x86_64 ]
=* ruby-1.9.2-p320 [ x86_64 ]
ruby-1.9.3-p194 [ x86_64 ]
# => - current
# =* - current && default
# * - default
but if I run ruby -v it returns still 1.8.7.
$ ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
other return values:
$ whereis ruby
ruby: /usr/bin/ruby /usr/bin/ruby1.8 /usr/lib/ruby /usr/share/man/man1/ruby.1.gz
$ which rails
/usr/local/bin/rails
$ which ruby
/usr/bin/ruby
When you're typing ruby you're still hitting the system ruby, not the rvm ruby.
Did you follow all the directions here: https://rvm.io//rvm/install/ ?
It looks like you're running Linux -- did you see this section in the rvm install docs?
If you open a new shell and running:
$ type rvm | head -1
does not show "rvm is a function", RVM isn't being sourced correctly.
Ensure that RVM is sourced after any path settings as RVM and manipulates the path. If you don't do this, RVM may not work as expected.
If you are using GNOME on Red Hat, CentOS or Fedora, ensure that the Run command as login shell option is checked under the Title and Command tab in Profile Preferences. After changing this setting, you may need to exit your console session and start a new one before the changes take affect.
Also, rvm adds some lines to your .bashrc file to load itself into memory whenever you open a console session. It looks like this may be your issue.
In my .bashrc, for example, rvm inserted the following:
export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/lib/postgresql84/bin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
Is there something similar in yours? Also, if you're using z-shell you may need to take some extra steps that are outlined in the install docs.
Try
$ rvm use ruby-1.9.2-p320
then
$ ruby -v
what does this return?
This should change your ruby version to ruby-1.9.2-p320 in the current console and if you want it on every new opened terminal you may use --default option
try
$ rvm --default use ruby-1.9.2-p320
then
$ruby -v
should return ruby-1.9.2-p320 version in the current and in every new window terminal opened.
Any time you want to return to your system ruby installation
use
$ rvm use system

Using RVM, but can't set current Ruby version (Ubuntu 11.10)

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.

Resources