I have installed Ruby 2.1.2 using RVM on Ubuntu 14.04. It works the first time, but then I restarted the terminal and it didn't work anymore. I figured out that I had to type rvm use ruby-2.1.2 every time.
I have researched and found out that I had to set a default. I did that, but it stil doesn't work. I also checked that the .bash_profile and .profile files look right.
Can anyone help me with that?
I figured this out myself and now post this for future reference:
I had to check the setting 'use as login shell' in the gnome terminal. See "RVM can't set ruby as default" for reference.
Related
UPDATE: I just quit all instances of Terminal and opened a new window, and apparently the message is not showing anymore.
I uninstalled ruby-2.1.0, installed ruby-2.1.3 and made it the default with RVM on Mac OS X.
Now everytime I open a new terminal window I see this:
ruby-2.1.0 is not installed.
To install do: 'rvm install ruby-2.1.0'
I looked on .bashrc, .bash_profile, .profile and .rvmrc, but I don't see anything trying to use ruby-2.1.0. I also updated the .ruby-version files.
rvm list shows ruby-2.1.3 as the current and default ruby.
How do I stop that message from appearing?
When you go into a Rails project directory in your terminal, RVM looks up the .ruby-version file and if it finds it, it checks the Ruby version specified inside this file, then if that Ruby version is not installed on your system by RVM, it gives you the message you are getting.
This is actually very helpful, allowing to know your project is using a Ruby version which is not installed on your system
The solution for me was to just quit all instances of Terminal and reopen it.
If anyone else is having this problem, check also Ali's answer regarding the .ruby-version file.
I'll start by saying I'm not an expert at command-line, so I really only barely know what I'm doing.
I cannot get RVM and oh-my-zsh to play nice together. I've tried several different solutions posted around, some on SO, but nothing I have found seems to fix the issue.
Initially, someone else setup RVM on my machine. I later setup oh-my-zsh myself, and remember having a lot of trouble doing so.
My .zhsrc file is completely default except for these 2 lines
export PATH=$HOME/bin:/usr/local/bin:/usr/local/rvm/bin:$PATH
#pretty sure this line does nothing, although I've seen this fix around
# several places. I noticed that I don't seem to have an .rvm file in my
# home directory which would be an issue, but I have no idea how to
# go about correcting this.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
I added the /usr/local/rvm to the Path directive as zsh returns zsh: rvm command not found without it there. Otherwise most rvm command work, with the exception of rvm use which throws the following error:
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
I have ensured the profile preferences on my profile in iTerm2 are set to "Login Shell" as recommended by RVM
I have tried changing these preferences to the "Command" option and using the recommended /bin/bash/ --login as the command, however zsh no longer appears to work when this happens. Changing the command to /bin/zsh/ --login allows zsh to work again but does not solve the problem as I still get the "RVM is not a function" error when trying to run rvm use
The default ruby in RVM is set to 2.0.0. I can run ruby -v in my home folder and get the ruby version output which shows the default version.
Working on rails projects, I can run all rails commands IF the Gemfile specifies ruby 2.0.0, the default. However on a project that uses a different version, I get the following error:
Your Ruby version is 2.0.0, but your Gemfile specified 1.9.3
Then I cannot run rvm use 1.9.3 as it returns the above mentioned error.
How can I make zsh play nice with RVM?
Some info about my setup:
Mac OSX 10.9.1 (Mavericks)
iTerm2
Zsh 5.0.2 with oh-my-zsh
RVM 1.5.1
For me, I just had to add
source $HOME/.rvm/scripts/rvm
to my ~/.zshrc and it started working, after having the same error message as in this SO question.
Turns out that RVM was installed in the wrong place. When I had initially installed RVM I believe I did so with the sudo command, which ran the multi-user install (installed to /usr/local/rvm), and not the single user (should be in ~/.rvm/scrips/rvm), which is why all the posted solutions were not working for me.
I had to uninstall RVM with rvm implode. There were some permissions issues, so I had to manually go in and delete the files that could not be deleted. Ran the curl command to re-install RVM and now it's installed in the correct place.
Sourcing RVM in my .zshrc with [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" now works properly and I can switch between rubies.
#trustkr's answer worked for me, but would like to add...
I ran into this issue immediately after install of rvm. In order for the
source
to work in in the ~/.zshrc file to work, you will need either start a new terminal session and work there OR you can run
source ~/.rvm/scripts/rvm
in the same terminal session in which you installed.
[Mac OS 10.10.5 - iTerm - zsh]
I had the same issue added this one line at end of .zshrc file
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
and works now everything works fine on my ubuntu 16.04 operating system :)
You need to run the following:
$ source ~/.rvm/scripts/rvm
then run this
$ type rvm | head -n 1
and the result will be like
rvm is a shell function from /home/sun/.rvm/scripts/cli
Hope that helps!
Another solution :
1) In the terminal run :
which rvm
The output in my case is ---> /usr/share/rvm
2) Open .zshrc file
nano ~/.zshrc
add "source + the_path_to_your_rvm + /scripts/rvm", in my case it's :
source /usr/share/rvm/scripts/rvm
3) save the file (.zshrc)
4) close the terminal and open it again
I've been going over this for awhile now and can't seem to get it permanently resolved. Was hoping someone could clarify for me.
I'm pretty familiar with setting up my PATH and working with ZSH. I have a ton of custom helpers, plugins, etc. going on nicely.
But for some reason, when I do gem install gemname and attempt to use it globally, it occassionally says gem not found. I found this happening recently with zeus:
tmtm|master⚡ ⇒ gem which zeus
/Users/andrewmartin/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/zeus-0.13.3/lib/zeus.rb
tmtm|master⚡ ⇒ zeus
zsh: correct 'zeus' to '_zeus' [nyae]? n
zsh: command not found: zeus
I had the same problem recently with mailcatcher and was never really able to get it installed or working. I had a couple really good Rails buddies take a look, they were confused as well.
Here's my PATH:
tmtm|master⚡ ⇒ echo $PATH
/Users/andrewmartin/.rbenv/bin:/usr/local/share/npm/bin:/usr/local/bin/npm:/Users/andrewmartin/.rbenv/shims:/Users/andrewmartin/.rbenv/:/Users/andrewmartin/.rbenv/bin:/usr/local/bin:/usr/bin:/Users/andrewmartin/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/opt/ruby/bin:/Users/andrewmartin/Dropbox/Favorites/dotfiles/bin
Any idea why some of these common, global gems are simply not found in the zsh shell? Happy to share any other information that would make this helpful. I am using rbenv.
I figured it out!
Simple!
Whenever you install a new gem with rbenv, you have to use the rbenv rehash command. It said it found one, so I just deleted the one that existed, then typed it again. When I opened a new terminal, both mailcatcher and zeus were magically available to me.
Awesome! Thanks to this post by the way.
Whenever I go to a folder with a .rvmrc file, there is a warning:
Warning! PATH is not properly set up, '/home/me/.rvm/gems/ruby-2.0.0-p247/bin' is not available,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
to fix run: 'rvm use ruby-2.0.0-p247'.
I did rvm use ruby-2.0.0-p247, but the warning is still present.
Note: There are no errors, Im able to run my application just fine, but the warning is very annoying. Any ideas?
I was getting the same warning even after upgrading RVM to version 1.25.16. I was able to fix the warning by running:
rvm reset
Then when I ran:
rvm version
I did not receive the error anymore.
If you know what you're doing, and your PATH is set to what you want, you can suppress this message by putting the following in your ~/.rvmrc:
rvm_silence_path_mismatch_check_flag=1
This is handy if you use other path-manipulating programs like virtualenv, or if you just want to prefix your path with ~/bin or something.
I was able to get rid of this by doing
rvm get head
This was a bug and was handled with https://github.com/wayneeseguin/rvm/issues/2050 and was released as rvm stable 1.21.15 at 2013-07-29 19:15:30 -0700
I had the same problem too, and rvm get head didn't work for me, finally it was solved by running rvm get head --auto-dotfiles, then restarted the terminal and the annoying warning message disappeared! And the solution is found here: https://github.com/wayneeseguin/rvm/issues/2074
Hope this will help.
rvm get stable solved this for me
(as pointed out in comments on another answer by AndrewMarshall)
Okay, so I ran an export PATH command without realizing the implications and ran into the identical error, but I also lost all control of my typical commands like cd and pwd. I didn't want to reset the rvm tools I'd already installed per some of the answers above.
First attempt was to some sort of mac default path (found on google):
$ export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
Which actually solved my first problem of not having access to my typical command line tools, but was still getting the same error as #Santosh's initial problem. The next thing I did was navigate to my directory where I've set up rvm to start, and then to run a new export command as follows:
$ export PATH="$PATH"
This was how I initially set up rvm, and no more errors. Hope this helps someone
Make sure that you add the following at the end of your
~/.bash_profile OR ~/.zshrc file.
In this example our ruby version is ruby-2.6.1. Replace this with your ruby version.
export PATH=~/.rvm/gems/ruby-2.6.1/bin:$PATH
# RVM manual script for loading rvm to shell
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
This works for me.
Solved!
Warning! PATH is not properly set up, '/home/vaibhav/.rvm/gems/ruby-2.3.1/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.3.1'.
rvm get stable --auto-dotfiles
Next you might get below Error:
RVM is not a function, selecting rubies with ‘rvm use …’ will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use /bin/bash --login as the command.
Temporarily solution
I solved it temporarily by running source ~/.rvm/scripts/rvm it is the only solution it worked for me. but you have to run it every time you close the terminal. at least solves your emergency
I'm on a Mac running 10.6.4 Snow Leopard, and apparently ruby comes ready to go. But I'm new to Ruby, trying to learn the Rails framework, and so i decided to install the latest version 1.9.2. I followed the instructions here, but after I compile and install, when I run ruby -v I'm still getting 1.8.7. Anyone can help a noob out?
When I use which ruby I am getting usr/local/bin/ruby, so the path has changed and is correct.
UPDATE:
It seems I was having issues because I was using two login files to set my path (.bash_login and .profile). You can only use one, and the first one that exists and is readable will be used. I eventually switched to RVM and used .bash_login to load RVM into shell.
Well, the sw isn't lying to you. So something is not as you expect.
Try /usr/local/bin/ruby -v and see what version it is.
Added: Also, try locate ruby|more to see where the ruby files are on your system.
You may need to change your path to use your newly installed copy of ruby.
Added more: did you add the Path to your ~/.profile file as the instructions tell you to do in step 1?
Did you restart your terminal session after changing the ~/.profile file? (Quit and restart terminal.)