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

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

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.

Installed Ruby 1.9.3 but ruby -v keeps showing 1.8.7 every new terminal

Eventhough I have Ruby 1.9.3 installed via RVM, every time I open a new Terminal and run "ruby -v" I get:
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]
"rvm list" shows:
rvm rubies
ruby-1.9.3-p362 [ x86_64 ]
=* ruby-1.9.3-p374 [ x86_64 ]
# => - current
# =* - current && default
# * - default
I've tried entering "rvm use 1.9.3 --default" but it only works for the current terminal session. Opening new terminals always reverts back to 1.8.7.
I've also made sure that my ~/.bash_profile contains at the end:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
What can I do so that I don't have to type "rvm use 1.9.3" every time I open a terminal?
Make sure that your .rvm directory is in your PATH

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

Resources