我在这里遇到一个奇怪的问题。当我使用gemset
创建rvm
时,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*
为什么会这样?我该如何解决这个问题,所以这条路径在更改/创建gemset时不会发生变化?
答案 0 :(得分:0)
您以前似乎已经使用
安装了rails sudo apt get install rails
。
which rails
返回路径中rails
的第一次出现。
尝试此操作 - 首先执行sudo apt-get remove rails