【问题标题】:All rails projects - Bundler is using a binstub that was created for a different gem所有 rails 项目 - Bundler 使用的是为不同的 gem 创建的 binstub
【发布时间】:2015-03-19 17:47:17
【问题描述】:

在我所有的 Rails 项目中,当我运行 rails 时,我得到以下输出:

Bundler is using a binstub that was created for a different gem.
This is deprecated, in future versions you may need to `bundle binstub rails` to work around a system/bundle conflict.

我已经看到了处理项目的解决方案,但我会遇到系统范围的问题吗?

【问题讨论】:

  • 您是否尝试按照消息中的说明进行操作?
  • 当我运行命令时,我得到:rails 没有可执行文件,但您可能需要它依赖的 gem 中的一个。 railties 有:rails bundler 有:bundle, bundler

标签: ruby-on-rails-4 bundler


【解决方案1】:

如果您的系统中有 3.x 和 4.x,或者两个版本具有不同的 bin 名称,就会发生这种情况,在我的系统中,我使用 3.2.22,名称为 railties 和 4.x bin名称是 rails,Rubygems 会在第一次安装时为 gem 创建一个 binstubs,所以如果你像我一样先安装 4.x rails,其他 3.x 项目将有此消息。 rails 4.x 的 binstub 文件的最后一行是: 加载 Gem.bin_path('railties', 'rails', 版本)

而对于 3.x 来说是这样的 加载 Gem.bin_path('rails', 'rails', 版本)

警告消息来自 bundler gem 的 ruby​​gems_integration.rb 的第 344 行

def replace_bin_path(specs)
  gem_class = (class << Gem; self; end)
  redefine_method(gem_class, :bin_path) do |name, *args|
    exec_name = args.first

    return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle"

    spec = nil

    if exec_name
      spec = specs.find {|s| s.executables.include?(exec_name) }
      raise(Gem::Exception, "can't find executable #{exec_name}") unless spec
      unless spec.name == name
        warn "Bundler is using a binstub that was created for a different gem.\n" \
          "This is deprecated, in future versions you may need to `bundle binstub #{name}` " \
          "to work around a system/bundle conflict."
      end
    else
      spec = specs.find {|s| s.name == name }
      raise Gem::Exception, "no default executable for #{spec.full_name}" unless exec_name = spec.default_executable
    end

    gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
    gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
    File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
  end
end

所以解决方案是卸载所有导轨

gem uninstall rails

删除 binstub 文件(如果仍然存在)

which rails
rm -rf path_of_rails

并安装你实际使用的rails版本

gem install rails -v 3.2.22

【讨论】:

  • 键入 gem install rails -v 3.2.6 时,无法从 rubygems.org 下载数据 - SSL_connect 返回=1 errno=0 state=SSLv3 读取服务器证书 B:证书验证失败 (api.rubygems.org/specs.4.8.gz ) 这是错误
猜你喜欢
  • 1970-01-01
  • 2015-04-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多