Default Ruby not loading with RVM - ruby

Not sure if this issue is related to a recent Oh-My-ZSH update, but all of a sudden, my RVM default Ruby is not loading when opening a new Terminal window (instead, it loads the system Ruby).
I have added [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" to about every dotfile on my system (.zshrc, .zprofile, .zlogin, .profile, even .bashrc and .bash_profile for good measure).
RVM is loading when the session starts (I can manually switch to the default with rvm default), and $HOME/.rvm/bin is in my $PATH. If I switch to a directory with a .ruby-version and/or .ruby-gemset file, it loads that Ruby.
EDIT:
To clarify, my problem is that the default Ruby I declared with RVM (rvm use <RUBY VERSION> --default) is not being loaded when I start a new terminal session or when I cd out of a directory that has a .ruby-version file.
EDIT #2:
Here is the results of rvm list
{15:20}[]~ ➭ rvm list
rvm rubies
ruby-1.9.3-p550 [ x86_64 ]
ruby-2.0.0-p594 [ x86_64 ]
ruby-2.1.3 [ x86_64 ]
* ruby-2.1.4 [ x86_64 ]

So I half figured this out. I was attempting to set a default Ruby with the global gemset for that particular Ruby version (rvm use 2.1.4#global --default). When I set the default without the gemset, it persists and is loaded in each subsequent session.
In the past I have been able to load the default with a gemset. Not sure if this is an issue with the latest version of oh-my-zsh or rvm.

Related

RVM Ruby Default not working

Ok so first off I've seen almost all if not all the posts on this here and nothing has worked. Furthermore I don't know how but I have got this to work on a different environment which is basically a clone of my current set up. I just can't pin point what's different between the two.
Issue:
I have ruby-2.5.0 set as my default but on each new terminal session I get reverted back to ruby-2.3.3
So here's my RVM list
=> ruby-2.3.3 [ x86_64 ]
* ruby-2.5.0 [ x86_64 ]
2.5.0 set as my default, in my other env I simply ran
rvm use 2.5.0 --default
and I'd get 2.5.0 whenever I started a new session. That's not working here.
HERE is a gist with my bashrc, bash_profile, and zshrc files.
Got it working running these 2 commands
$ rvm alias create default 2.5.0
$ rvm default 2.5.0

RVM default ruby not used when opening terminal

This issue seems to relate to Default Ruby not loading with RVM, but the answer do not help me.
On my Ubuntu 14 LTS, I've got 2 rubies installed in rvm and set 2.2-head as default using rvm use 2.2-head --default. After reopening terminal (login shell is configured) 2.2 does not get set as current
$ rvm list
rvm rubies
=> ruby-2.1.5 [ x86_64 ]
* ruby-2.2-head [ x86_64 ]
# => - current
# =* - current && default
# * - default
I couldn't find any .ruby-version or .rvmrc in current ($HOME) folder (or its parents).
Meanwhile I tried removing system ruby (1.9.3), but this has no effect, too.
What did I miss?
Problem could be solved by rebooting system, although I don't know why this works
Have you followed the instructions on https://rvm.io/rubies/default?

Setting default Ruby version outside RVM

When I input:
ruby -v
I get:
ruby 1.8.7
but with:
rvm list
I get:
=* ruby-2.2.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
What is causing this mismatch? How do I correct it so I always use 2.2.1?
I would guess there is something wrong with your $PATH and you are referencing the system ruby maybe? I would recommend double checking the install directions.
You could also try running again:
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
Finally, once you get that working, I also find using .ruby-version and .ruby-gemset files in repos/folders very helpful. See "Typical RVM Project Workflow" for more info.

How to make RVM use the default automatically

RVM doesn't use the default Ruby version on both my Mac and Ubuntu server.
This is what I get when I do rvm list on my Mac:
rvm rubies
* ruby-2.1.2 [ x86_64 ]
# => - current
# =* - current && default
# * - default
And what I get on Ubuntu:
rvm rubies
* ruby-2.1.2 [ i686 ]
# => - current
# =* - current && default
# * - default
They are already the default and only version available, but I have to manually type rvm use 2.1.2 each time when I need to do some Ruby stuff. I guess I could put that command into .profile or the like, but it feels hackish since I'm expecting RVM to use the default version.
Does anyone have a better solution?
I resolved the problem.
I tried rvm use ruby-2.1.2 --default multiple times and it didn't work. There's two things I did:
I moved this line:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
in ~/.bash_profile to the last line. See "How to use "RVM --default" on MacOSX".
Somehow some application decided to add itself to this file and making it the first in the path.
Run rvm get head.
This solved the problem for me on my Mac.

ERROR: Missing RVM environment file After Doing rvm upgrade command - Passenger 4.0.23

I was running ruby 2.0.0-p247 on my Mac Mini Server (Mavericks 10.9.1). I read that there was a security vulnerability so I decided to upgrade to use the latest Ruby patch 2.0.0-p353. I did the following commands:
gem update --system (RubyGems 2.1.11)
rvm get stable (RVM 1.25.0)
rvm upgrade 2.0.0-p247 2.0.0-p353 (which should have moved my gemsets)
There is nothing in my system that I can find that references 2.0.0-p247 in rvm which is what I expected. When I go to ~/myuser/.rvm/environments there is no file 2.0.0-p247.
I am now attempting to start passenger. I had version 4.0.23 enterprise installed. I attempted to run rvmsudo passenger-install-apache2-module but got an error.
cd /Users/myuser/.rvm/gems/ruby-2.0.0-p353#mygemset/gems/passenger-enterprise-server-4.0.23
/Users/myuser/.rvm/wrappers/ruby-2.0.0-p353# mygemset/rake apache2:clean apache2 RELEASE=yes
# /Users/myuser/.rvm/wrappers/ruby-2.0.0-p353# mygemset/rake apache2:clean apache2 RELEASE=yes
ERROR: Missing RVM environment file: '/Users/myuser/.rvm/environments/ruby-2.0.0-p247#LightBeCorp_Rails4Ruby2'
Here are statements in my .bashrc file related to rvm if this will help.
[[ -s "$HOME/.rvm/scripts/rvm" ]]
PATH="$PATH:$HOME/.rvm/gems/ruby-1.9.3-p327#mygemset/bin:/.rvm/rubies/ruby-1.9.3-p327/bin/ruby:/.rvm/rubies/ruby-1.9.3-p448/bin/ruby:/.rvm/rubies/ruby-2.0.0-p353/bin/ruby:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
I did a rvm list rubies command. ruby-2.0.0-p247 is not listed.
Any help would be appreciated. I will continue looking. I plan to post a link to this in the Phusion Passenger group.
UPDATE 12/21/2013 12:20 pm
I updated my .bashrc file to the following since I no longer use the other rubies in my Rails applications. I still get the error when I try to run rvmsudo passenger-install-apache2-module.
[[ -s "$HOME/.rvm/scripts/rvm" ]]
PATH="$PATH:$HOME/.rvm/rubies/ruby-2.0.0-p353/bin/ruby:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
looks like a bug, please open a ticket here: https://github.com/wayneeseguin/rvm/issues
Indeed this was a bug, to fix it run:
rvm get head
rvm gemset reset_env
you can repeat the reset_env operation for every gemset that is broken:
rvm ruby#gemset do rvm gemset reset_env
There might be a cached bin file in your RVM path. In my case, it's "/usr/local/rvm/bin/unicorn"
Also, you may not directly having the gem in your Gemfile. In my case, I do not have "unicorn" in my Gemfile although I had "capistrano-unicorn".
So that the system will try to use the global cached file "/usr/local/rvm/bin/unicorn".
The file's content may using a ruby that you no longer use.
if [[ -s "/usr/local/rvm/environments/ruby-2.0.0-p247" ]]
then
source "/usr/local/rvm/environments/ruby-2.0.0-p247"
exec unicorn "$#"
else
echo "ERROR: Missing RVM environment file: '/usr/local/rvm/environments/ruby-2.0.0-p247'" >&2
exit 1
fi

Resources