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

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.

Related

ruby not found but 2.4.0 installed by rvm indeed

I am new to Ruby. Following the tutorials: https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rvm-on-ubuntu-16-04 and https://scotch.io/tutorials/a-crash-course-in-ruby.
The output of terminal (OS ubuntu 16.04):
me#xxx:~$ rvm list
rvm rubies
=* ruby-2.4.0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
me#xxx:~$ ruby --version
The program 'ruby' is currently not installed. You can install it by typing:
sudo apt install ruby
me#xxx:~$ rvm use ruby-2.4.0
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
Any idea why? Thanks.
UPDATE
me#xxx:~$ rvm alias create default 2.4.0
Creating alias default for ruby-2.4.0....
me#xxx:~$ ruby -v
The program 'ruby' is currently not installed. You can install it by typing:
sudo apt install ruby
UPDATE2
Part of ~/.bashrc
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
The last line added by me just now. Still not working.
Theres different ways to install ruby, you can try with rbenv, i did it with this guide and it worked perfectly, maybe u can give it a shot:
https://gorails.com/setup/ubuntu/16.04
Generally, you just have to make sure that your bash is run with the option
--login
(in the config of your terminal) and restart your console.
maybe following code can help you.but I don't know how to deal with it perpetually.
$ source ~/.bashrc
$ source ~/.bash_profile

ruby -v different from rvm

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.

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.

Why does Ruby or RVM seem stuck at 1.8.7 on Linux Mint?

I am on Linux Mint 12.
I installed RVM and ran these commands:
rvm 1.9.2
rvm --default use 1.9.2
but ruby -v still outputs ruby 1.8.7.
sudo apt-get install ruby1.9.2 returns saying 1.9.1 is the latest version.
How do I get Ruby to be running on 1.9.2?
When I run rvm list like suggested at "Ruby 1.9.2 keeps reverting back to 1.8.7 after installing it using RVM", it outputs:
rvm rubies
ruby-1.8.7-p352 [ x86_64 ]
=> ruby-1.9.2-p290 [ x86_64 ]
So I think I must have a configuration issue. My OS seems to be defaulting to the wrong version of Ruby.
I ran:
sudo apt-get remove ruby
But had no change.
You add string [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" into ~/.bashrc? First, show your echo $PATH output. If this looks like (rvm paths before system paths):
/home/ayunin/.rvm/gems/ruby-1.9.3-rc1/bin:/usr/bin:/bin:/usr/bin/X11
Then you ran into the magick. Restart your terminal, and show ruby version. If does not work - you can launch rvm implode and reinstall all, yes.
It looks like Linux Mint 12 has ruby-rvm already installed (at least on my machine) so could this be a problem?
you can stick with that but then I think you will need to add your username to the rvm group with usermod -a -G username rvm.
I removed removed ruby-rvm completely (with apt-get) and then followed the installation instructions from https://rvm.beginrescueend.com/rvm/install/ for 'single user' thus all my rvm files are located in ~/.rvm/bin/rvm
I added the line for rvm in my .bashrc and tested with 1type rvm | head -1`.
After that rvm install 1.9.2 just worked and I installed it into ~/.rvm/rubies/ruby-1.9.2
After that rvm use --default 1.9.2 set all up correctly.

RVM doesn't switch Rubies

I'm running Ruby 1.9.1p243 on CentOS, and I decided to install rvm to handle upgrading to 1.9.2 or downgrading to 1.8.7 (whichever turns out to work better for rails3).
I followed the instructions here: http://rvm.beginrescueend.com/rvm/install/ and everything installed correctly. I was able to compile and install Ruby 1.8.7, 1.9.1, and 1.9.2.
However, if I try to actually switch to one of the rvm installed Rubies, with rvm use 1.8.7, for example, nothing works. My system still uses the Ruby I have installed in /usr/local/bin/ruby.
An example of the output I get:
$ rvm use 1.8.7
$ ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux]
$ which ruby
/usr/local/bin/ruby
$ rvm use 1.9.2
$ ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux]
$ which ruby
/usr/local/bin/ruby
I have no idea why this is happening, and I can't seem to find anything online about the issue either. Any help would be appreciated.
Just came across the same problem.
Instead of appending the following script to ~/.bash_profile, append it to ~/.bashrc:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
And then restart the terminal.
Typically rvm support is easiest via IRC (#rvm on freenode) - in this particular case, what does running "type rvm | head -n1" show? it should show "rvm is a function". If not, that means the line to source rvm isn't being run correctly and hence switching doesn't work. Typically this means you either have a return in your ~/.bashrc or you missed adding the line to source rvm.
Your install it as root account.
Try this in shell:
[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm"
before rvm switch operation. I add this line in my profile file and now all is ok.
Can be a problem of Terminal and
you should try to close your Terminal's window
and to open new one. :)
Try again to see if it has changed...
I've been struggling with setting default rvm ruby to no avail, until I've tried this:
sudo bash -l -c 'rvm alias create default ruby-1.9.3-p392'
"sudo" is for writing into /usr/local/rvm/config/alias (in my example it would contain "default=ruby-1.9.3-p392")
"bash -l" is to make sure it runs all the scripts (/etc/profile, /etc/bash.bashrc, etc..) of login shell

Resources