System and rvm Ruby versions are different - ruby

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.

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

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

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 !!!

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.

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