【问题标题】:ActiveRecord requires ruby version >= 2.2.2ActiveRecord 需要 ruby​​ 版本 >= 2.2.2
【发布时间】:2016-11-25 11:06:21
【问题描述】:

我需要用于 rake 的 activerecord,但是当我尝试安装它时它说:

activesupport-5.0.0.1 requires ruby version >= 2.2.2,
which is incompatible with the current version, ruby 1.9.3p484

我尝试将 ruby​​ 与 rbenv 更改为 2.2.2

rbenv versions

输出

系统 * 2.2.2(由 /home/user/.rbenv/version 设置) 2.3.1

但是当我使用 ruby​​ -v 时,它会说

ruby 1.9.3p484(2013-11-22 修订版 43786)[x86_64-linux]

也尝试删除它,但是当我安装 rake 时

sudo apt-get install rake

我得到了这个输出

将安装以下额外的包:

libruby1.9.1 ruby​​ ruby​​1.9.1

但是,我需要激活 ruby​​ 版本 2.2.2 或更高版本(ruby -v)来安装活动记录,这样我才能执行 rake 命令。

【问题讨论】:

  • 你跑rbenv global 2.2.2了吗?
  • 是的,我做到了,并且在 rbenv 版本中有一个 *,但看起来 1.9.3p484 仍然处于活动状态

标签: ruby activerecord rake


【解决方案1】:

你把事情搞砸了。

sudo apt-get install rake

是一个系统范围的debian包,它对rbenv一无所知。删除它以及删除系统红宝石。

然后,做:

rbenv global 2.2.2
gem install rake # ⇐ THIS

【讨论】:

    【解决方案2】:

    我得到了帮助并解决了这个问题。就我而言,我将 gemfile.lock 从

        GEM
      remote: http://rubygems.org/
      specs:
        activemodel (5.0.0.1)
          activesupport (= 5.0.0.1)
        activerecord (5.0.0.1)
          activemodel (= 5.0.0.1)
          activesupport (= 5.0.0.1)
          arel (~> 7.0)
        activesupport (5.0.0.1)
          concurrent-ruby (~> 1.0, >= 1.0.2)
          i18n (~> 0.7)
          minitest (~> 5.1)
          tzinfo (~> 1.1)
        arel (7.1.4)
        concurrent-ruby (1.0.2)
        i18n (0.7.0)
        minitest (5.9.1)
        mysql2 (0.4.5)
        rake (11.3.0)
        thread_safe (0.3.5)
        tzinfo (1.2.2)
          thread_safe (~> 0.1)
    
    PLATFORMS
      ruby
    
    DEPENDENCIES
      activerecord
      mysql2
      rake
    
    BUNDLED WITH
       1.13.6
    

    到这个(最重要的是activerecord版本):

    GEM
      remote: http://rubygems.org/
      specs:
        activemodel (3.1.3)
          activesupport (= 3.1.3)
          builder (~> 3.0.0)
          i18n (~> 0.6)
        activerecord (3.1.3)
          activemodel (= 3.1.3)
          activesupport (= 3.1.3)
          arel (~> 2.2.1)
          tzinfo (~> 0.3.29)
        activesupport (3.1.3)
          multi_json (~> 1.0)
        arel (2.2.1)
        builder (3.0.0)
        i18n (0.6.0)
        multi_json (1.0.4)
        mysql2 (0.3.11)
        rake (0.9.2.2)
        tzinfo (0.3.31)
    
    PLATFORMS
      ruby
    
    DEPENDENCIES
      activerecord
      mysql2
      rake
    
    BUNDLED WITH
       1.13.6
    

    然后安装 activerecord 和我需要的所有其他东西

    gem install activerecord -v 3.1.3
    sudo apt-get install libmysqlclient-dev
    sudo apt-get install ruby1.9.1-dev
    gem install activerecord-mysql2-adapter
    gem uninstall mysql2
    gem install mysql -v 0.3.11
    

    而且耙子起作用了。

     rake db:migrate[]
    

    希望这会对某人有所帮助! :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多