2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rvmコマンドを使用した際に受けたWarning! PATH is not properly set up, ... is not at first placeという警告

Last updated at Posted at 2017-04-19

rvm gemset listを実行したら以下のような警告を毎回貰うようになった。

Warning! PATH is not properly set up, ... 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.3.0@rails_sample_app'.
         To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.

指示通りrvm get stable --auto-dotfilesを実行しても状況は変わらず。PATHに問題があるとのことなので確認してみることに。

$ echo $PATH
/Library/Frameworks/Python.framework/Versions/3.4/bin:/Users/username/.rvm/gems/ruby-2.3.0@rails_sample_app/bin:/Users/username/.rvm/gems/ruby-2.3.0@global/bin:/Users/username/.rvm/rubies/ruby-2.3.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/mysql/bin:/Users/username/.rvm/bin:/Users/username/.rvm/bin:/Users/username/.rvm/bin:/Users/username/.rvm/bin
/.bashrc
## rvm
#export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

export HISTCONTROL=ignoreboth:erasedups # only display the latest command of duplicates

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
/.bash_profile
export PATH=$PATH:/usr/local/mysql/bin

# Setting PATH for RVM
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
#PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
#export PATH
alias brew="env PATH=${PATH/\/Users\/hironorisama\/\.pyenv\/shims:/} brew"

# A bash function to display a growl notification using iTerm's magic
# escape sequence. This version will work under screen.
growl() { echo -e $'\e]9;'${1}'\007' ; return ; }

# It checks if there’s a directory named venv (or virtualenv or whatever you use). If there is, it activates the virtual environment automagically.
function cd {
    builtin cd "$@"
    if [ -d "venv" ] ; then
        source venv/bin/activate
    fi
}

関連記事を並行読みしていたのでソースは思い出せないが、今回のrvmによるこの警告はPATHのrvmが何よりも最初に来ないといけないとどこかで書いてあった。

#解決策

結論から言うと~/.bash_profileのrvmのPATHをファイルの最後に配置する。

Typically, this happens because something else, such as node/go...etc, change the PATH variable after rvm does, you can check the PATH variable by echo $PATH and see the result to see if anything occures befor rvm's path

node, pythonといった他の言語の導入によってPATHが変わってしまうために起こることが多いらしい。

/.bash_profile
export PATH=$PATH:/usr/local/mysql/bin

# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
alias brew="env PATH=${PATH/\/Users\/hironorisama\/\.pyenv\/shims:/} brew"

# Setting PATH for RVM
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

# A bash function to display a growl notification using iTerm's magic
# escape sequence. This version will work under screen.
growl() { echo -e $'\e]9;'${1}'\007' ; return ; }

# It checks if there’s a directory named venv (or virtualenv or whatever you use). If there is, it activates the virtual environment automagically.
function cd {
    builtin cd "$@"
    if [ -d "venv" ] ; then
        source venv/bin/activate
    fi
}

refrence by when l typed "rvm use ..." command in ubuntu terminal , it remains me ........

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?