【问题标题】:Install RVM with current ruby and rails installed安装 RVM 并安装当前的 ruby​​ 和 rails
【发布时间】:2013-08-15 19:07:55
【问题描述】:

我使用 Rails 3.2.14 和 Ruby ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux] 没有 RVM。

除了我当前的 Rails 版本之外,我还需要在同一台机器上使用 Rails 2.3。我搜索了允许我在同一台机器上同时使用它们的原因,并找到了它的 RVM。

我正在使用Oh-My-ZSH,并且我输入了这个命令来安装 RVM

\curl -L https://get.rvm.io | bash -s stable

安装后我收到此警告

  * WARNING: You have '~/.profile' file, you might want to load it,
    to do that add the following line to '/home/dexter/.bash_profile':

      source ~/.profile

而且我不知道我应该如何处理我目前的 ruby​​ 和 rails。 同时使用 Rails 3 和 Rails 所需的步骤是什么?前面的警告又是什么

➜  ~  ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
➜  ~  which ruby
ruby: aliased to bundled_ruby

当我输入 rvm list 时:

rvm list

rvm rubies


# No rvm rubies installed yet. Try 'rvm help install'.

当我尝试去我的名为 Triton 的项目时

➜  ~  cd ~/Desktop\ item/Triton
RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,
you can ignore these warnings with 'rvm rvmrc warning ignore /home/dexter/Desktop item/Triton/Gemfile'.
To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.

ruby-1.9.3-p448 is not installed.
To install do: 'rvm install ruby-1.9.3-p448'

【问题讨论】:

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


    【解决方案1】:

    使用 rvm 安装您需要的任何版本的 ruby​​。 例如

    $ rvm install 1.8.7
    $ rvm use 1.8.7
    $ gem install rails -v 2.3
    

    使用 gemset 返回到您的系统版本的 ruby​​

    $ rvm use system
    $ ruby -v
    (Should be) ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
    

    要切换到 1.8.7(例如)使用

    $ rvm use 1.8.7
    

    您也可以将 rvm 用于两个版本的 rails 和一个 ruby​​ 版本 - 尝试 gemsets

    $ rvm install 1.9.3-p194
    $ rvm use 1.9.3-p194
    $ rvm gemset create rails2
    $ rvm gemset use rails2
    $ gem install rails 2.3
    $ rvm gemset create rails3
    $ rvm gemset use rails3
    $ rvm install rails -v 3.2.14
    

    有关 gemset 的完整信息,请查看http://rvm.io/gemsets

    【讨论】:

      【解决方案2】:

      您会得到no rvm rubies installed yet,因为 rvm 范围内没有红宝石。您的“主要”系统 ruby​​ 与使用 rvm 安装的 ruby​​ 没有任何共同之处,这是故意的。你应该在 rvm 中安装 ruby​​:

      rvm install ruby-1.9.3-p194
      

      如果你想要特定的路径级别。

      你可以使用它

      rvm use ruby-1.9.3-p194
      

      如果你想要特定的路径级别。您应该使用

      创建新的gemset
      rvm gemset create PutNameHere
      

      然后使用它(如果我没记错应该自动完成)

      rvm gemset use PutNameHere
      

      从那时起,您应该以常规方式安装 gem,它们应该进入具有特定 ruby​​ 版本的特定 gemset。

      编辑:如果你想用rails 2 安装ruby 1.8.6,你应该:

      rvm install ruby-1.8.6 # this may take a while
      rvm use ruby-1.8.6
      rvm create gemset Triton # or any other name you like
      rvm gemset use Triton
      gem install rails -v '~> 2.3' # or an other version you want, but much better will be to do:
      bundle install #of course in your app root directory - it will install all necessary gems     altogeter with rails 2 or whatever you have specified
      

      【讨论】:

      • Gemset 用于定义我想在项目中使用的 Rails 版本?
      • 是的,gemset 用于将所有 gem 存储在一个包中,您可以创建多个 gemset 并在它们之间轻松切换。如果您将在一个中完全弄乱 gem - 没问题,只需删除整个 gemset,创建新并执行bundle install,您应该会收到全新的工作安装(如果 Gemset 没问题)。
      • 如果还想将 rails 2 与 ruby​​ 1.8.6 一起使用,您能否补充一下您的答案?我有点困惑:/
      • 你的意思是如果我想在 rails 2 中启动一个项目,我应该输入 rvm use ruby​​ 1.8.6 然后 rails new 吗?这将在 Rails 2.3 中。如果我想在 rails 3 中启动一个项目,我应该输入 rvm use ruby​​ 1.9.3 then rails new ?
      • ruby != rails,这是两个不同的东西。您应该指定 ruby​​ 和 rails,因此如果您想开始新项目,您应该首先安装带有您想要的修订版的 rails。
      【解决方案3】:

      我收到了这个警告并继续我的安装没有问题...你能输入“rvm list”吗,它是否将 rvm 识别为命令?您是否在安装导轨时遇到问题?

      【讨论】:

      • 你的 rvm 应该没问题。继续您的安装。 'rvm install ruby​​ 1.9.3' 然后'gem install rails'
      • 我目前的 ruby​​ 和 rails 怎么样?我在安装 RVM 之前就有了它们。
      • 因此,如果您愿意,请保留它们;)它们不应干扰 rvm。编辑:对不起,我认为这是我帖子下的评论;p
      猜你喜欢
      • 2013-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-27
      • 2014-06-13
      相关资源
      最近更新 更多