$PATH is not properly set up - ruby

I just ran 'rvm get stable' to be given the below error;
Warning! PATH is not properly set up, '/Users/jamesbkemp/.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'.
Previous to running 'rvm get stable' I ran 'brew upgrade ruby' to Ruby 2.2.2.
'echo $PATH' returns the below:
/usr/local/heroku/bin:/Users/user/.rvm/gems/ruby-2.2.1/bin:/Users/user/.rvm/gems/ruby-2.2.1#global/bin:/Users/user/.rvm/rubies/ruby-2.2.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/user/.rvm/bin:/Users/user/.rvm/bin
I don't understand what the issue is here or why when i run 'ruby -v' it returns 'ruby 2.2.1p85'.
Running 'rvm list' returns the below, as well as the same PATH error message detailed above;
ruby-2.0.0-p353 [ x86_64 ]
ruby-2.0.0-p451 [ x86_64 ]
ruby-2.1.0 [ x86_64 ]
ruby-2.1.5 [ x86_64 ]
=* ruby-2.2.1 [ x86_64 ]
ruby-2.2.2 [ x86_64 ]
Can anyone help?

Put RVM code at the start of $PATH
I just had the same problem. I went to terminal and entered subl ~/ which opens up your home folder on Sublime Text (or you can use another text editor).
I then clicked on every file starting with ., e.g. .bash_profile, .bashrc, .mkshrc, .zshrc
Whenever I saw this line:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
I changed it to this:
export PATH="$HOME/.rvm/bin:$PATH" # Add RVM to PATH for scripting
That way, the RVM code is at the start of $PATH. Then I quit Terminal and started it up again to make sure those config files were loaded.

Related

RVM Warning! PATH is not properly set up

I just installed rvm on my mac, but I receive this warning on global commands
Warning! PATH is not properly set up, '/usr/local/rvm/gems/ruby-1.9.3-p194/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-1.9.3-p194'.
My $PATHS confirms the warning:
$echo :$PATH:
/usr/local/rvm/bin:/usr/local/heroku/bin:/usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194#global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:
As suggested, I first tried rvm get stable --auto-dotfiles to no avail, then I checked my shell initializations files. My /.bash_profile:
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
export PATH=/usr/local/share/python:$PATH
PATH=$PATH:$HOME/bin:/opt
My /Users/User/.bash_profile seems to be the culprit:
export PS1="[\w]$"
alias ll='ls -laGH'
alias .='echo $PWD'
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
# rvm
PATH=/usr/local/rvm/bin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
The reason is if I remove Heroku Toolbelt and the rvm paths (which were answers suggested by other stack overflow questions), /usr/local/rvm/gems/ruby-1.9.3-p194/bin would be in first place and the problem is resolved. However, I don't know what to do with the Heroku Toolbelt. Additionally, shouldn't PATH=/usr/local/rvm/bin:$PATH place rvm first anyways?
I must be missing some trivial solution.
Additional notes:
$rvm --debug get head produces no installation notes regarding this except for the warning posted above.
Update: calling rvm system fixes the problem, but only in the current shell session. $echo $PATH now produces:
:/usr/local/heroku/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/rvm/bin:
What is a permanent fix?
I have the same problem with rvm 1.25.26.
solution:
I've modified ~/.bashrc as follows:
## rvm
PATH="$GEM_HOME/bin:$HOME/.rvm/bin:$PATH" # Add RVM to PATH for scripting
[ -s ${HOME}/.rvm/scripts/rvm ] && source ${HOME}/.rvm/scripts/rvm
causing:
Warning is fired at __rvm_path_match_gem_home_check() function in
$HOME/.rvm/scripts/functions/cli.
If the beginning of $PATH does not start from $GEM_HOME/bin, a warning message is displayed.
__rvm_path_match_gem_home_check()
{
(( ${rvm_silence_path_mismatch_check_flag:-0} == 0 )) || return 0
[[ -n "${GEM_HOME:-}" ]] || return 0
case "$PATH:" in
($GEM_HOME/bin:*) true ;; # all fine here
(*:$GEM_HOME/bin:*)
__rvm_path_match_gem_home_check_warning "is not at first place"
;;
(*)
__rvm_path_match_gem_home_check_warning "is not available"
;;
esac
}
In my case, Heroku had added the following to my .bashrc:
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
Notice how it's prepending itself to the path. All I had to do was switch it around to:
### Added by the Heroku Toolbelt
export PATH="$PATH:/usr/local/heroku/bin"
And my problem was solved!
If you don't have Heroku, look for anything else that may be prepending itself to your path. Really, RVM just wants to make sure it has a fair chance to load Ruby before any gems that include themselves in the path get loaded.
The solution was to run
$rvm install ruby-head
$rvm use ruby-head
with an optional $rvm docs generate-ti
I was using an outdated version of Ruby on my system, updating it to the current version fixed it.
Search your config files for:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
Replace that line with:
export PATH="$HOME/.rvm/bin:$PATH" # Add RVM to PATH for scripting
To make sure the RVM code is at the start of your $PATH. Also make sure no other code puts itself at the start of $PATH.
Because I was using the ubuntu version of rvm, I needed to put this in my .profile:
PATH="$GEM_HOME/bin:/usr/share/rvm/bin:$PATH" # Add RVM to PATH for scripting
[ -s /usr/share/rvm/scripts/rvm ] && source /usr/share/rvm/scripts/rvm
I resolved this problem in Ubuntu 18.04 by commenting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session as a function
in ~/.bashrc file, as the same line was there in ~/.bash_profile file.
Right. I'dumping this answer as I spent hours researching with no success. I hope this will save someone else some time.
My problem was having 2 ruby heads installed and apparently, the ruby version was also an issue.
➜ rvm list
Warning! PATH is not properly set up, '/home/ma/.rvm/gems/ruby-1.8.7-head/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-1.8.7-head'.
To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.
rvm rubies
=> ruby-1.8.7-head [ x86_64 ]
ruby-1.8.7-p374 [ x86_64 ]
ruby-2.3.0 [ x86_64 ]
ruby-2.4.0 [ x86_64 ]
* ruby-head [ x86_64 ]
# => - current
# =* - current && default
# * - default
In this case, (trying all the above solutions, this and this) setting my default to ruby-head [ x86_64 ] and restarting the terminal the Warning! AND my current ruby version was persisting as the above snippet shows.
To fix that:
rvm remove ruby-1.8.7-head
Now, if I restart the terminal:
➜ rvm list
rvm rubies
ruby-1.8.7-p374 [ x86_64 ]
ruby-2.3.0 [ x86_64 ]
ruby-2.4.0 [ x86_64 ]
=* ruby-head [ x86_64 ]
# => - current
# =* - current && default
# * - default
It seems, and the end of .bashrc, you need to guarantee the rvm path is at the beginning of $PATH

rvm on OS 10.9 a few problems: second export path to .bash_profile, missing 2.0 path, and missing files

1)
I have this error every time I load a new bash terminal
-bash: /etc/profile.d/sm.sh: No such file or directory
-bash: /etc/profile.d/rvm.sh: No such file or directory
I saw this previously asked question with the answer to simply delete the references from .bashrc. But the answer is unaccepted and unvoted and the references to these files are not in .bashrc but in ~/etc/profile
I should note that I don't have a profile.d directory under /etc. I have files profile and profile~orig
2)
RVM added a second export path after I ran rvm get stable, but did not include a reference to Ruby 2.0.0 in either.
.bash_profile
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH=/usr/local/bin:/Users/mcb/.rvm/gems/ruby-1.9.3-p448/bin:/Users/mcb/.rvm/gems/ruby-1.9.3-p448#global/bin:/Users/mcb/.rvm/rubies/ruby-1.9.3-p448/bin:/Users/mcb/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
My instinct is to combine them into one, eliminate repeats, and add the references to ruby 2 manually. I also added the $PATH: myself, since that didn't work the first time either.
3)
This is clearly not right
my-macbook-pro:~ mcb$ rvm get sable --auto-dotfiles
Warning! PATH is not properly set up, '/Users/mcb/.rvm/gems/ruby-2.0.0-p247/bin' is not available,
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.0.0-p247'.
cat: /Users/mcb/.rvm/help/get: No such file or directory
So, long story short I'm starting to get worried about trying to fix anything else myself without some sort of guidance for fear of just making things worse.
for 1) check /etc/profile for those two files references
for 2) remove export PATH=/usr/local/bin:/Users/mcb/.rvm/gems/ruby-1.9.3-p448/bin:/Users/mcb/.rvm/gems/ruby-1.9.3-p448#global/bin:/Users/mcb/.rvm/rubies/ruby-1.9.3-p448/bin:... from ~/.bash_profile
for 3) rvm get sable => rvm get stable
I think the problem is that you are adding ruby 1.9.3 explicitly in your PATH, and that's a job that rvm shoud do.
In my case I have no direct reference to any of the ruby installations in my PATH.
Try cleaning your path from anything ruby and rvm related, and let rvm load as a function.
This is the .bash_profile on my computer (with rvm and brew working):
export PATH=/usr/local/bin:/usr/local/sbin:$PATH:/usr/local/opt/ruby/bin
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
To check if rvm is correctly configured you can run:
type rvm | head -n 1
The result should be: "rvm is a function"
Checkout rvm official webpage for more details on how it works: https://rvm.io/rvm/install

Rails 4 my .bashrc file does not reflect latest ruby version

I have upgraded to Rails 4 and have the following versions installed (see below). The problem is that my .bashrc file still have references to ruby-1.9.2. Is this a problem and how do I correct this?
$ rvm list
rvm rubies
ruby-1.9.2-p320 [ x86_64 ]
ruby-1.9.3-p392 [ x86_64 ]
=* ruby-2.0.0-p247 [ x86_64 ]
$ rails -v
Rails 4.0.0
.bashrc
PATH="/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/git/bin:/Users/francoisvdhoven/.rvm/bin:/Users/francoisvdhoven/.rvm/bin/npm:/Users/francoisvdhoven/.rvm/bin:/bin:/Users/francoisvdhoven/.rvm/bin/node:/Users/francoisvdhoven/.rvm/gems/ruby-1.9.2-p320/bin:/Users/francoisvdhoven/.rvm/gems/ruby-1.9.2-p320#global/bin:/Users/francoisvdhoven/.rvm/rubies/ruby-1.9.2-p320/bin"
Thanks for your help!
Francois
You should be ok to remove these specific paths from your .bashrc file.
A typical rvm installation should not impact your .bashrc beyond the following line in it:
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
Also, your .bash_profile should only have this one line in it:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
With these entries, ruby locations in your $PATH variable will be appropriately set on-the-fly when you use rvm to select which ruby you wish to work with... thereby removing any need to hard-set any ruby paths explicitly in your .bashrc file.

After Installation RVM and Ruby 1.9.3 every Bash path change RVM Initialization Script is printed

I installed the latest RVM - Ruby Version Manager - and installed Ruby 1.8.7 and 1.9.3 on OSX Lion with XCode 4.3.3 using clang rvm install 1.9.3 --reconfigure --debug -C --enable-pthread --with-gcc=clang as the regular way did not work due to a GCC error. I did get one error clang: error: unsupported option '--with-libyaml, but Ruby 1.9.3 worked and I could run WPScan that needs at least 1.9.2 .
But now every time I run a command to change folder such as cd I get a long Bash script printed related to RVM - see http://pastebin.com/UAm38Vcm and:
.
How can I stop it from doing that?
Update I
Added a comment at RVM at Github as well https://github.com/wayneeseguin/rvm/issues/1039 , but as that issue is not 100% related and as I need this solved as soon as possible I opened a thread here with more data.
Update II
I realized the RVM Initialization script is the one that is being printed: https://github.com/wayneeseguin/rvm/blob/master/scripts/initialize . No idea why though..
Update IV
My .bashrc
# define aliases
alias sudo='sudo '
#alias ruby='ruby1.9'
alias apacherestart='sudo apachectl -k restart'
# define hist properties
HISTFILESIZE=1000000000
HISTSIZE=1000000
# define path to programs
PATH=/opt/local/bin:opt/local/sbin:/opt/subversion/bin:/opt/local/apache2/bin/:/opt/local/lib/python2.4/site-packages/django/bin:$PATH
# define manpath
MANPATH=/opt/local/share/man:$MANPATH
# export env vars
export HISTFILESIZE HISTSIZE PATH MANPATH
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
My .bash_profile
source ~/.bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Your cd command has somehow become aliased or a function has been created named "cd".
You can undo those with either:
unalias cd
or
unset -f cd
You should be able to revert temporarily with
unalias cd
It appears that you will need to figure out what was changed in your .bashrc and revert all those changes. If the installation script is at all sanely written, it should have made backups, or document somehow what was changed.

Cannot change RVM gemset from shell script via `rvm gemset use`

(See update at bottom)
I feel like I'm missing something terribly obvious here, but I can't change gemsets from within a shell script. This minimal script demonstrates:
#!/usr/bin/env bash
rvm gemset use "testing"
I even tried the instructions from the Scripting RVM page (although it didn't seem necessary):
#!/usr/bin/env bash
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
# Then try to load from a root install
source "/usr/local/rvm/scripts/rvm"
else
printf "ERROR: An RVM installation was not found.\n"
fi
rvm gemset use "testing"
Still no go.
Interestingly enough, if I try to run the script without first creating the "testing" gemset, I get ERROR: Gemset 'testing' does not exist, rvm gemset create 'testing' first. However, if I create the gemset and then run the script, I get no output from the script and the gemset is not changed (according to rvm info). I am able to perform other RVM gemset actions, such as creating gemsets and trusting .rvmrc files, from within the script.
[Update]
Of course, the environment is changing, as indicated by a call to rvm info from within the script. How do I get these changes to persist/affect the calling shell? Or, if that's not possible (as indicated here), is there any way to set the current RVM gemset based on input to a script?
Had exactly the same problem, and here's the solution:
#!/bin/bash
# IMPORTANT: Source RVM as a function into local environment.
# Otherwise switching gemsets won't work.
[ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm"
# Enable shell debugging.
set -x
rvm 1.9.2#gemset_a
rvm gemdir
gem env gemdir
rvm 1.9.2#gemset_b
rvm gemdir
gem env gemdir
What I've found out is that your interactive shell has got rvm() and its helpers, whereas script's environment has not got them. rvm binary is executed instead, partially working and thus causing some confusion.
I ended up implementing the functionality I wanted as a function instead of a shell script.
function rvmrc {
rvm gemset create $1
rvm gemset use $1
echo "rvm gemset use $1" > .rvmrc
rvm rvmrc trust
}
RVM isn't loading correctly because it loads on your .bashrc or .bash_profile, which are run at login.
You can run the rvm gemset use with a login shell:
bash -l -c "rvm use RUBY_VERSION#GEMSET_NAME"
Hope it helps!

Resources