2016-03-29 98 views
0

我使用Mac OS X,我有一些配置文件和bash_profile。這裏是我的文件的內容:

cat ~/.profile 
PATH=/usr/local/git/bin:$PATH 
export PATH 

cat ~/.bash_profile 
export JAVA_HOME=$(/usr/libexec/java_home) 
export M2_HOME=/Users/myName/Tools/apache-maven-3.2.5 
export GIT_HOME=/usr/local/git 
export PATH=$PATH:$M2_HOME/bin:$GIT_HOME/bin 


### Added by the Heroku Toolbelt 
export PATH="/usr/local/heroku/bin:$PATH" 
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi 
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi 

MYSQL=/usr/local/mysql/bin 
export PATH=$PATH:$MYSQL 
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH 

### ADDED FOR SUBLIME SYMLINK 
export PATH=/usr/bin/local/bin:$PATH 

這裏是$ PATH的內容:

echo $PATH 
/usr/bin/local/bin:/Users/myname/.rbenv/shims:/Users/myname/.rbenv/shims:/usr/local/heroku/bin:/usr/local/git/bin:/usr/local/git/bin:/usr/local/git/bin:/Users/myname/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rspec-3.4.0/lib/rspec.rb:/usr/bin/local/bin:/Users/myname/.rbenv/shims:/Users/myname/.rbenv/shims:/usr/local/heroku/bin:/usr/local/git/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/ImageMagick/bin:/Users/myname/Tools/apache-maven-3.2.5/bin:/usr/local/git/bin:/usr/local/mysql/bin:/Users/myname/Tools/apache-maven-3.2.5/bin:/usr/local/git/bin:/usr/local/mysql/bin 

我不明白爲什麼我有這樣的/用戶/ myname/.rbenv/versions/2.2.2/lib/ruby​​/gems/2.2.0/gems/rspec-3.4.0/lib/rspec.rb。我怎麼能刪除它?我在〜/ .profile和〜/ .bash_profile中都看不到它。

感謝您的幫助

+0

「rbenv init」是否添加到路徑中? – hft

+0

bash忽略.profile如果.bash_profile存在,那麼.profile是無關緊要的。但.bash_profile中的PATH添加似乎已經執行了兩次,還有一些其他添加(「/usr/local/git/bin:/usr/local/git/bin:/Users/myname/.rbenv/versions/2.2。 2/lib/ruby​​/gems/2.2.0/gems/rspec-3.4.0/lib/rspec.rb「)。這是從哪裏來的,我不確定。你有.bashrc文件嗎? –

回答

1

這是由rbenv設置的RSpec的binstub。

  1. 使用rbenv rehash運行rbenv shell 2.2.2
  2. gem uninstall -a rspec
  3. rbenv rehash
  4. 刷新外殼,以確保您的.rbenv/versions/...文件夾是當前
  5. 確保您通過rbenv使用Ruby 2.2.2。

您應該只有這條線的一個: if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

也已經有了一噸重複的在你的$ PATH很可能你的.bashrc文件被加載多次,或者你是運行的另一個RC腳本你不知道的:

/Users/myname/.rbenv/shims 
/Users/myname/.rbenv/shims 
/Users/myname/.rbenv/shims 
/Users/myname/.rbenv/shims 
/Users/myname/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rspec-3.4.0/lib/rspec.rb 
/Users/myname/Tools/apache-maven-3.2.5/bin 
/Users/myname/Tools/apache-maven-3.2.5/bin 
/bin 
/opt/ImageMagick/bin 
/sbin 
/usr/bin 
/usr/bin/local/bin 
/usr/bin/local/bin 
/usr/local/bin 
/usr/local/git/bin 
/usr/local/git/bin 
/usr/local/git/bin 
/usr/local/git/bin 
/usr/local/git/bin 
/usr/local/git/bin 
/usr/local/heroku/bin 
/usr/local/heroku/bin 
/usr/local/mysql/bin 
/usr/local/mysql/bin 
/usr/sbin 

參見: https://github.com/rbenv/rbenv/wiki/Understanding-binstubs http://dan.carley.co/blog/2012/02/07/rbenv-and-bundler/