【问题标题】:Rails 5: Array values in the parameter to `Gem.paths=` are deprecatedRails 5:不推荐使用 `Gem.paths=` 参数中的数组值
【发布时间】:2016-10-18 06:11:23
【问题描述】:

基于 actioncable-examples 构建 websockets 应用程序。在启动服务器、运行 rake 等时,我不断收到消息:

Array values in the parameter to `Gem.paths=` are deprecated.

这里没有找到解决方案,但确实找到了。我想在这里发布问题和答案,以便它可用。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-5


    【解决方案1】:

    我在 RubyGems 问题 #1551 here 中找到了答案。 binstubs,bin 文件夹中的文件,需要更新。最好的方法是:

    bundle update spring
    bundle exec spring binstub --remove --all
    bundle exec spring binstub --all
    

    这为我解决了问题。

    【讨论】:

      【解决方案2】:

      我的rails 4.2.7 应用程序也面临同样的错误,我修复了错误以更新bin/spring 文件第11 行

      Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) }
      

      【讨论】:

      • 这个答案很有用,因为它指出了问题的根本原因。但是,上面接受的答案给出了重新生成相同 binstub 文件的说明,这应该更安全,因为没有手动输入错误代码的风险。
      【解决方案3】:

      tl;dr bin/spring binstub,您可能需要在此之前更新 spring(如果 1.3.3 spring

      spring1.3.31.6.4 一直在其 binstub 中使用数组作为 GEM_PATH 值。

      rubygems-2.6.0 中,他们计划使用give up on arrays,但显然这些 binstubs 在很多项目中都出现了。所以他们在rubygems-2.6.1restored the array handling,但带有弃用警告。这两个对应于Ruby 2.4.0

      【讨论】:

      • bundle update spring 是第一个命令?
      • @Richard_G 是吗?如果您正在运行1.3.3 <= spring < 1.6.4,它是。 spring >= 1.6.4 不需要。
      • @Richard_G 实际上,如果您将答案替换为我的答案,我可以。然后我可以删除我的。我只是不确定你是否同意。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-15
      • 2015-09-19
      • 2020-08-02
      • 2019-05-13
      • 1970-01-01
      相关资源
      最近更新 更多