我在这里遇到了一个奇怪的问题。当我使用rvm
创建gemset
时,which rails
的路径会发生变化。以下是我在终端上运行的命令。我在SO上提到了相关的问题,但对我没有太大帮助。
someuser@ubuntu-laptop:~/sandbox/some_app$ rvm use 2.0.0
Using /home/someuser/.rvm/gems/ruby-2.0.0-p247
someuser@ubuntu-laptop:~/sandbox/some_app$ which ruby
/home/someuser/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
someuser@ubuntu-laptop:~/sandbox/some_app$ which rails
/home/someuser/.rvm/gems/ruby-2.0.0-p247/bin/rails
someuser@ubuntu-laptop:~/sandbox/some_app$ rvm gemset use some_app (I also tried rvm gemset use 2.0.0@some_app --create)
Using ruby-2.0.0-p247 with gemset some_app
someuser@ubuntu-laptop:~/sandbox/some_app$ which ruby
/home/someuser/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
someuser@ubuntu-laptop:~/sandbox/some_app$ which rails
/usr/local/bin/rails (<--- the path changed!)
rails s
或bundle
命令出现错误:
someuser@ubuntu-laptop:~/sandbox/some_app$ rails s
-bash: /usr/local/bin/rails: /usr/bin/ruby1.8: bad interpreter: No such file or directory
我必须运行以下命令来修复路径:
someuser@ubuntu-laptop:~/sandbox/some_app$ rvm use 2.0.0
Using /home/someuser/.rvm/gems/ruby-2.0.0-p247
someuser@ubuntu-laptop:~/sandbox/some_app$ which rails
/home/someuser/.rvm/gems/ruby-2.0.0-p247/bin/rails
我在.bash_profile
中有以下条目:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
为什么会这样?我该如何解决这个问题,这样在更改/创建宝石集时路径就不会改变?
您以前似乎会使用安装轨道
sudo apt get install rails
。
which rails
返回rails
在路径中的第一次出现。
试试这个-首先通过执行sudo apt-get remove rails
来删除本地轨道