【问题标题】:Difference between rvm and rvm uservm 和 rvm 使用之间的区别
【发布时间】:2011-09-12 17:21:58
【问题描述】:

这是一个简单的问题,但我似乎无法在文档中找到一个好的答案(我是 RVM 的新手)。

rvm use ruby​​-1.9.2-head@rails3 和 rvm ruby​​-1.9.2-head@rails3 有什么区别?

正在尝试为 2 个项目(rails 3.1 和 3.0.9)设置我的 gemset 的两个版本,并且打算这样做:

rvm gemset create proj1 proj2
rvm 1.9.2-head@proj1
gem install rails -v 3.1

rvm 1.9.2-head@proj2
gem install rails -v 3.0.9

然后试图弄清楚是否使用

rvm 1.9.2-head@proj1 

rvm use 1.9.2-head@proj1

切换到该项目/gemset。因此我的问题......

【问题讨论】:

    标签: ruby ruby-on-rails-3 rvm


    【解决方案1】:

    AFAIK,单独的 rvm 命令旨在用于针对多个版本的 ruby​​/ruby gem 运行某些东西。例如,您可以指定rvm 1.9.2,1.8.7 test.rb,它将使用两个rubies 执行test.rb。

    相比之下,rvm use 设置您当前的 shell 环境以使用您通过的任何 ruby​​。所以如果你 rvm use 1.9.2@proj1,你的下一个 ruby​​ 命令可以简单地是 ruby whatever.rb,然后 rvm 将使用你的 proj1 gem set 选择 ruby​​ 1.9.2。

    所以,总而言之,当你想运行多个 ruby​​ 时使用 rvm 1.9.2,1.8.7 something.rb,当你想设置当前 shell 将使用的 ruby​​ 时使用 rvm use 1.9.2

    编辑

    这在评论中看起来很糟糕,所以我正在编辑。这些 rvm 命令的输出如下所示:

    ## RVM use will set the ruby for this shell
    [Moe:~]$ rvm use 1.9.2
    Using /Users/nunya/.rvm/gems/ruby-1.9.2-p290
    [Moe:~]$ ruby -e 'puts `rvm current`'
    ruby-1.9.2-p290
    
    ## rvm without the use will execute the command with all the rubies passed, 
    ## but will leave the shells ruby alone.
    [Moe:~]$ rvm 1.9.2,1.9.3 -e 'puts `rvm current`'
    ruby-1.9.2-p290
    ruby-1.9.3-preview1
    [Moe:~]$ ruby -e 'puts `rvm current`'
    ruby-1.9.2-p290
    # with a single ruby:
    [Moe:~]$ rvm 1.9.3 -e 'puts `rvm current`'
    ruby-1.9.3-preview1
    [Moe:~]$ rvm current
    ruby-1.9.2-p290
    

    【讨论】:

    • 非常有意义,但是当我使用 rvm 1.9.2@proj1 然后执行 rails server 或其他任何东西时,它的工作方式与我运行 rvm 使用 1.9.2@proj1 相同。所以我还是一头雾水?
    • 也许您的 shell 之前设置为使用 1.9.2@proj1?我不明白。
    【解决方案2】:

    两者的区别

    rvm use 1.9.2
    

    简单明了

    rvm 1.9.2
    

    只是 RVM 是否会显示有关从一个 ruby​​|ruby@gemset 更改为另一个的信息。 'use' 关键字只会导致 RVM 显示更改后的设置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-20
      • 1970-01-01
      • 2014-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-24
      相关资源
      最近更新 更多