RVM PATH is not properly set up - ruby

I've recently run into the following error from rvm when trying to upgrade my ruby version.
Warning! PATH is not properly set up, '/home/sam/.rvm/gems/ruby-2.2.1/bin' is not at first place,
My echo $PATH is as follows:
/usr/local/heroku/bin:/home/sam/.rvm/gems/ruby-2.2.1/bin:/home/sam/.rvm/gems/ruby-2.2.1#global/bin:/home/sam/.rvm/rubies/ruby-2.2.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/sam/.rvm/bin:/home/sam/.rvm/bin:/home/sam/.rvm/bin:/home/sam/.rvm/bin
My .bashrc has the following lines in it
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
And .bash_profile has:
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
And my rvm info is as follows
Warning! PATH is not properly set up, '/home/sam/.rvm/gems/ruby-2.2.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.2.1'.
ruby-2.2.1:
system:
uname: "Linux bitey0asus 3.13.0-77-generic #121-Ubuntu SMP Wed Jan 20 10:50:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux"
system: "ubuntu/14.04/x86_64"
bash: "/bin/bash => GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]"
updated: "10 minutes 55 seconds ago"
path: "/home/sam/.rvm"
ruby:
interpreter: "ruby"
version: "2.2.1p85"
date: "2015-02-26"
platform: "x86_64-linux"
patchlevel: "2015-02-26 revision 49769"
full_version: "ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]"
homes:
gem: "/home/sam/.rvm/gems/ruby-2.2.1"
ruby: "/home/sam/.rvm/rubies/ruby-2.2.1"
binaries:
ruby: "/home/sam/.rvm/rubies/ruby-2.2.1/bin/ruby"
irb: "/home/sam/.rvm/rubies/ruby-2.2.1/bin/irb"
gem: "/home/sam/.rvm/rubies/ruby-2.2.1/bin/gem"
rake: "/home/sam/.rvm/rubies/ruby-2.2.1/bin/rake"
environment:
PATH: "/usr/local/heroku/bin:/home/sam/.rvm/gems/ruby-2.2.1/bin:/home/sam/.rvm/gems/ruby-2.2.1#global/bin:/home/sam/.rvm/rubies/ruby-2.2.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/sam/.rvm/bin:/home/sam/.rvm/bin:/home/sam/.rvm/bin:/home/sam/.rvm/bin"
GEM_HOME: "/home/sam/.rvm/gems/ruby-2.2.1"
GEM_PATH: "/home/sam/.rvm/gems/ruby-2.2.1:/home/sam/.rvm/gems/ruby-2.2.1#global"
MY_RUBY_HOME: "/home/sam/.rvm/rubies/ruby-2.2.1"
IRBRC: "/home/sam/.rvm/rubies/ruby-2.2.1/.irbrc"
RUBYOPT: ""
gemset: ""
I found a solution to a similar problem here. But apparently not close enough (the proposed solution had no effect).
Anyway if anyone has any ideas, I'd appreciate it. I'm a little clueless on the ins and outs of rvm so I'm a bit in the dark here. Thanks in advance
Edit:
I tried reversing the order of the two rvm lines in my .bashrc but this did not help the error, nor did it change the order shown by echo $PATH.

Your PATH does not start with /home/sam/.rvm/gems/ruby-2.2.1/bin because you have a line prepending the Heroku toolbelt path.
You can check this is true by running this in your terminal:
PATH=/home/sam/.rvm/gems/ruby-2.2.1/bin:$PATH rvm info
It shouldn't complain.
The problem comes from Heroku toolbelt modifiying your env in ways rvm doesn't care for.
As per this post, the fix is to change your .bashrc like so:
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
# Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
You can remove the rvm line from .bash_profile

To solve it I just changed in my .profile file:
PATH="$HOME/bin:$HOME/.local/bin:$PATH"
to
PATH="$PATH:$HOME/bin:$HOME/.local/bin"

Related

iTerm2 Setup as Login Shell, RVM Still Gives Error

I have been trying to install Ruby-2.6.1 on my Macbook Pro for a couple of days now, and I have followed many posts and blog posts to try to get the setup correct, but I am not successful. I always get the following when trying to set the default Ruby with RVM:
picklemac:~ jblanchard$ rvm use default ruby-2.6.1
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 an example.
I have followed the link, but with no success. I have iTerm2 setup as a login shell:
In .bashrc I have the following:
# 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" ]] && . "$HOME/.rvm/scripts/rvm"
And in .bash_profile I have the following:
# rvm
# export PATH="/Users/jblanchard/.rvm/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
As I said, I have read and tried a number of things to get iTerm2 and my Mac setup properly, including How to make zsh run as a login shell on Mac OS X (in iTerm)?. Also, because I am trying to upgrade from Ruby 2.3 I have read a number of posts on just how to do that - again with no success.
What am I doing wrong?
Additional Info
I am able to successfully list the installations using rvm list:
picklemac:~ jblanchard$ rvm list
ruby-2.6.0 [ x86_64 ]
=* ruby-2.6.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
This is interesting, because RVM indicates Ruby-2.6.1 is the default, but when I use ruby -v the return is:
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin17]
I was able to successfully make the change to Ruby-2.6.1. First, I uncommented the export line in .bash_profile:
# rvm
export PATH="/Users/jblanchard/.rvm/bin:$PATH" #UNCOMMENTED
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
After stopping and starting iTerm2 I issued the command to use Ruby-2.6.1 and received a warning, but then:
picklemac:~ jblanchard$ rvm use default ruby-2.6.1
Warning! PATH is not properly set up, /Users/jblanchard/.rvm/gems/ruby-2.6.1/bin is not at first place.
Usually this is caused by shell initialization files. Search for PATH=... entries.
You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
To fix it temporarily in this shell session run: rvm use ruby-2.6.1
To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.
Using /Users/jblanchard/.rvm/gems/ruby-2.6.1
The change to Ruby-2.6.1 was made. It appears I do need to run rvm get stable --auto-dotfiles to fix the warning, which I would prefer to silencing it. Now, when running ruby -v the return is:
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]

Error about ruby & rvm default version

on a CentOS 6.5 server, I installed ruby through rvm and set the ruby-2.0.0-p451 as default.
$ rvm --default ruby-2.0.0-p451
However, when I'm running script from Crontab
I got an error like
`require': no such file to load -- rubygems (LoadError)
so I checked ruby -v test.rb, it tells me that I'm using ruby 1.8.5 (2006-08-25) [x86_64-linux] not the default ruby-2.0.0-p451. And I also checked with /usr/bin/ruby.
$ /usr/bin/ruby -v
ruby 1.8.5 (2006-08-25) [x86_64-linux]
My question is how to use ruby-2.0.0-p451.
Thanks
It looks like, your path variable is not set correctly. It is generally defined in your ~/.profile, it should contain something like these 2 lines:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads R
I just simply changed the /usr/bin/ruby as a link to solve the problem as below:
mv /usr/bin/ruby /usr/bin/_ruby
ln -s /usr/local/rvm/rubies/ruby-2.0.0-p451/bin/ruby

RVM / ZSH - Always shows "Upgraded http://rubygems.org/ to HTTPS" when gem installing

I'm curious why it keeps showing this message any not doing anything about it. Is m RVM is setup incorrectly?
I'm using zsh and have [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* in my .zprofile
check this files:
~/.gemrc
/etc/gemrc
it has nothing to do with rvm

RVM is not a function even when running command as login shell [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Cannot use RVM-installed Ruby with sudo
I'm running into the same "RVM is not a function..." error when executing the command sudo rvm use 1.9.3 as everyone else, but try as I might, I cannot seem to resolve it. I've read and followed through with all of the common troubleshooting tips, but nothing seems to work...
My System --- OS: Ubuntu 12.10 --- Ruby Version: 1.9.3 --- RVM Version: 1.18.3
I have done the following to try to repair the issue:
Checked the 'Run command as login shell' option in the "Title and Command" tab for Terminal preferences
Added the following code block to ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.zprofile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
if test -f ~/.rvm/scripts/rvm; then
[ "$(type -t rvm)" = "function" ] || source ~/.rvm/scripts/rvm
fi`
Running user$ source ~/.rvm/scripts/rvm and then user$ type rvm | head -n 1 DOES return rvm is a function. But then running sudo rvm use 1.9.3 returns "RVM is not a function"
What else can I do to resolve this issue?
You can not run rvm with sudo, sudo is running a new process which defeats the function approach which can change current running shell environment.

Need help switching from RVM to RBENV

Alright so I imploded RVM and switched to rbenv but now I think I'm having all kinds of problems with the gem path. I think some part of my system still thinks gems are supposed to be found with RVM and it's messing everything up. I'm terrible at fixing config issues like this so your help is greatly appreciated.
This is my $PATH:
/Users/home/.rbenv/shims:/Users/home/.rbenv/bin:/Users/home/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/home/.rvm/bin
So as you can see .rvm is still in the $PATH, is this my problem? How do I fix it?
Here is my gem env(This was what I got before I manually moved some directories to better match the path, now I get the same error(below)
as when I run ruby or bundle):
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.2 (2014-05-08 patchlevel 95) [x86_64-darwin15.0]
- INSTALLATION DIRECTORY: /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /Users/home/.rbenv/versions/2.1.2/bin/ruby
- EXECUTABLE DIRECTORY: /Users/home/.rbenv/versions/2.1.2/bin
- SPEC CACHE DIRECTORY: /Users/home/.gem/ruby/2.1.0
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
- /Users/home/.rbenv/versions/2.1.2/bin
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/home/.rbenv/versions/2.1.2/bin
- /usr/local/Cellar/rbenv/0.4.0/libexec
- /Users/home/.rbenv/shims
- /Users/home/.rbenv/bin
- /Users/home/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/home/.rvm/bin
My current version of ruby is 2.1.2 and it is looking into 2.1.0 still.
Here is my .bash_profile
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
Here is my .profile
eval "$(rbenv init -)"
When I run the ruby or bundle command I get this error:
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'
I did some tinkering with the path and manually relocated the gem directories, and I think I've done more harm than good. Thanks for the help. If you don't know the answer could someone please comment the best way to completely scrub ruby and the gem path settings so I can get a fresh reinstall? Do I just uninstall rbenv?
My RVM implode script is here -- you can edit is as you like.
https://github.com/sixarm/rvm-implode-systemwide-danger
The script does RVM implode, systemwide, and is dangerous. The script will seek and destroy RVM installations, rvm gems, .rvmrc files, and then search your entire system for lingering files and and references.
Suggestions and pull requests are very welcome. I'm the author.
The entire script is copy/paste below for reference. The link above is probably better because it will have any updates, changes, improvements, etc.
#!/bin/sh
#
# Uninstall RVM (Ruby Version Manager) systemwide:
# THIS IS DANGEROUS.
#
# This script tries to eliminate RVM everywhere on the system,
# by doing these steps:
#
# * Run `rvm implode`
# * Delete all known RVM-related files everywhere on the system.
# * Delete all users' home directory `.rvm` directories and `.rvmrc` files.
# * Uninstall all known RVM gems.
# * Search the system for potential lingering items and print them.
#
# ## Use at your own risk
#
# This script is not advanced:
#
# * it does not do any error checking
# * it does not ensure anything worked
# * it does not guarantee success
#
# If it doesn't work for you, please let us know and we'll improve it.
#
# We welcome feedback, patches, and pull requests.
#
# ## Warnings
#
# Some of the script lines may report missing directories.
#
# For example, a Mac system typically has a /Users/ directory,
# whereas a Linux system typically has a /home/ directory.
# You can delete the lines that you don't need, if you like.
#
# If rvm implode gives errors like this loop:
#
# line 72: /usr/local/rvm/scripts/rvm: No such file or directory
#
# then the rvm setup is bonked and we can delete the rvm script
# by hand then run this script again; rvm implode won't work,
# but the rest of the script will do a decent job of deleting
# any lingering rvm files and reporting any remainders.
#
# Command: rvm-implode-systemwide-danger
# Version: 2.0.0
# Created: 2011-08-22
# Updated: 2015-01-25
# License: GPL
# Contact: Joel Parker Henderson (joel#joelparkerhenderson.com)
##
set -euf
out () { printf %s\\n "$*" ; }
out "rvm implode"
rvm implode
out "remove rvm files from system-wide areas"
sudo rm -rf /usr/local/bin/rvm
sudo rm -rf /usr/local/rvm
sudo rm -rf /etc/rvmrc
sudo rm -rf /etc/profile.d/rvm.sh
out "remove rvm files from all likely user areas"
sudo rm -rf /home/*/.rvm
sudo rm -rf /home/*/.rvmrc
sudo rm -rf /Users/*/.rvm
sudo rm -rf /Users/*/.rvmrc
sudo rm -rf $HOME/.rvm
sudo rm -rf $HOME/.rvmrc
sudo rm -rf $(dirname $HOME)/*/.rvm
sudo rm -rf $(dirname $HOME)/*/.rvmrc
out "uninstall rvm gem as current user and with sudo"
gem uninstall -a -q rvm
sudo gem uninstall -a -q rvm
out "delete rvm group"
sudo /usr/sbin/groupdel rvm
out "try to find any remaining .rvmrc files, in case you want to delete them"
sudo find -L / -name .rvmrc
out "try to find rvm text in configuration files, in case you want to edit thme"
sudo find -L / -type f | grep "\(bash_login\|bash_profile\|bashrc\|profile\|zshenv\|zshrc\|zlogin\|zlogout\|zprofile\)$" | xargs -I{} grep -Iil "rvm" {}
Ensure that you are checking all of your "rc" files. This includes ~/.bashrc and ~/bash_login, if they exist.
Using a tool like grep can help you find them.
grep 'rvm' -l ./.* maybe, to get the filenames that any reference to rvm may be in.

Resources