链接红宝石到RVM [英] Link ruby to RVM

查看:83
本文介绍了链接红宝石到RVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图寻找一个小时左右的答案,但没有运气。我已经在我的rvm上安装了 ruby​​-2.0.0 ,但系统只检测到旧的 ruby​​-1.9.3 !我将 / usr / bin / ruby​​ 中的sym链接改为指向我的〜/ .rvm ruby​​,现在我当我运行 ruby​​ -v

时,得到以下内容:

  ruby​​ 2.0.0p451 (2014-02-24修订版45167)[x86_64-linux] 

但是,当我尝试启动 rails server 我得到的错误说我目前的ruby版本是 1.9.3 我跑了 gem env 并且得到了一个令人惊讶的结果:

pre $ RubyGems环境:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION:1.9.3(2012-04-20 patchlevel 194)[x86_64-linux]
- 安装目录:/var/lib/gems/1.9.1
- RUBY EXECUTABLE:/usr/bin/ruby1.9.1
- 可执行目录:/ usr / local / bin
- RUBYGEMS平台:
- ruby​​
- x86_64-linux
- 创业板路径:
- /var/lib/gems/1.9.1
- /home/username/.gem/ruby/1.9.1
- 创业板配置:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- install=> --no-rdoc --no-ri
- update=> --no-rdoc --no-ri
- 远程来源:
- http://rubygems.org/

您可以看到它指向错误的位置。我试着修改 .gemrc 来让它起作用,但它仍然拒绝改变它的ruby安装目录。我不知道如何解决它。我尝试删除它们,并开始新鲜但显然它们不是通过 apt-get 安装的,所以我不知道如何删除它们!



任何帮助将非常感谢。
更多信息:

  $ gem -v 
1.8.23
code $>


解决方案

第一个列表在RVM中的ruby版本

  rvm list 

p>

  ruby​​-1.9.3-p484 [x86_64] 
= * ruby​​-2.1.0 [x86_64]

#=> - 当前
#= * - 当前&&默认
#* - 默认

要使用像

  rvm使用ruby-2.1.0 

你可以像这样设置默认的ruby

  rvm use --default ruby​​-2.1.0 

现在检查您的ruby版本

  ruby​​ -v 



为了确保非交互式shell能够访问RVM, h2>

编辑 .bashrc 使用此命令

  sudo gedit /home/$USER/.bashrc 

确保您拥有这些在那里。

  PATH = $ PATH:$ HOME / .rvm / bin#将RVM添加到PATH以编写脚本
[[-s/home/`whoami`/.rvm/scripts/rvm]]&& source/home/`whoami`/.rvm/scripts/rvm

现在编辑您的.bash_profile使用此命令

  sudo gedit /home/$USER/.bash_profile 

确保你有这些行。如果不添加它。

  if [-f$ HOME / .bashrc];然后
源$ HOME / .bashrc
fi

重新启动您的终端。 / p>

I tried looking for an answer for about an hour but no luck. I have installed ruby-2.0.0 with my rvm but the system only detects the old ruby-1.9.3 !I changed the sym link in /usr/bin/ruby to point to my ~/.rvm ruby and now I get the following when I run ruby -v

ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-linux]

However when I try to start a rails server I get the error which says my current ruby version is 1.9.3 I ran gem env and got a surprising results:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.23
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
  - INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
  - RUBY EXECUTABLE: /usr/bin/ruby1.9.1
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /var/lib/gems/1.9.1
     - /home/username/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "install" => "--no-rdoc --no-ri"
     - "update" => "--no-rdoc --no-ri"
  - REMOTE SOURCES:
     - http://rubygems.org/

As you can see it is pointing to the wrong location. I tried modifying .gemrc to get it to work but it still refuses to change it's ruby installation directory. I have no idea how to fix it. I tried removing them all and starting fresh but apparently they are not installed via apt-get so I don't know how to remove them!

Any help will be very much appreciated. Just for further info:

$ gem -v                                                    
1.8.23

解决方案

First list ruby versions in RVM

rvm list

For example mine says

   ruby-1.9.3-p484 [ x86_64 ]
=* ruby-2.1.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

To use a ruby version use command like

rvm use ruby-2.1.0

You can set default ruby like this

rvm use --default ruby-2.1.0

Now check your ruby version

ruby -v

To ensure that non-interactive shells have access to RVM

Edit .bashrc using this command

sudo gedit /home/$USER/.bashrc

Make sure you have these lines there. If not add it.

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "/home/`whoami`/.rvm/scripts/rvm" ]] && source "/home/`whoami`/.rvm/scripts/rvm"

Now edit your .bash_profile using this command

sudo gedit /home/$USER/.bash_profile

Make sure you have these lines there. If not add it.

if [ -f "$HOME/.bashrc" ]; then
  source $HOME/.bashrc
fi

Restart your terminal.

这篇关于链接红宝石到RVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆