Ruby 捆绑机和错误的垃圾桶?

Ruby 捆绑机和错误的垃圾桶?,ruby,bundler,Ruby,Bundler,我运行rails s或bundle-exec-rails s时收到以下警告: 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. 这是什么意思?通过查看bundler站点,我对bin

我运行
rails s
bundle-exec-rails s
时收到以下警告:

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.
这是什么意思?通过查看bundler站点,我对binstubs的理解是,您可以为其设置可执行文件,因此,您可以只执行
bin/blabla
,而不是运行
bundle exec bla
。所以这个错误是说我的
绑定器
没有设置到正确的位置

当我运行
包时,我得到了这个输出

rails has no executables, but you may want one from a gem it depends on.
  railties has: rails
  bundler has: bundle, bundler
我不明白我的系统试图告诉我什么,它没有破坏任何东西,但我有一种预感,如果我不修复它,这可能会变成一个更大的问题

ruby 2.0.0p247
哪个红宝石

/Users/evan/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
哪个捆绑机

/Users/evan/.rvm/gems/ruby-2.0.0-p247/bin/bundler
Rails 4.0.2

编辑:

因此,如果我运行nag消息中的命令:

  bundle config --delete bin    # Turn off Bundler's stub generator
  rake rails:update:bin         # Use the new Rails 4 executables
最后,我用
bundle exec
命令得到了
未初始化的常量Bundler
错误,我找到的唯一解决方法是重新运行
bundle安装--binstubs
,这会在本文开始时返回nag消息。

对我有效的是

rm-rf-bin/*

然后打开一个新的终端会话并


bundle-exec-rake-app:update:bin
我可以通过使用
git-log-p bin/rails查看
bin/rails
的提交历史来修复这个问题

当前生成内容的错误是:

#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'rails' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
  Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('railties', 'rails')
原始的、无错误的内容是:

#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application',  __FILE__)
require_relative '../config/boot'
require 'rails/commands'
当我还原原始bin/rails内容时,警告消息消失了。以前的尝试在所有
bundle exec
命令上都返回了
未初始化常量Bundler
错误,但现在它们可以工作了。值得注意的是,原始内容似乎正是rails new blabla在rails 4.0.x中生成的内容

尽管如此,我还是想知道为什么第一个代码块会导致问题,因为它正是
bundle安装--binstubs
生成的

编辑:结果表明此解决方案不起作用。将此修复程序推送到heroku暂存服务器,heroku在启动时出错:所有
bin/rails
命令都会抛出
未初始化的常量绑定器
,heroku会启动
bin/rails服务器……
,因此这不是一个真正的修复程序

编辑2:

如果我将这两行添加到第二个块(原始bin/rails内容),则所有
bin/rails
命令都将再次工作:

require 'rubygems'
require 'bundler/setup'
我的猜测是,第二行是用来修复我所遇到的绑定器错误的

有趣的是,当我试图编辑本文中的第一个代码块以尝试调试哪一行抛出警告时,我所做的任何更改都会导致所有
rails
命令失败,除了OP.wird中的nag注释外,没有任何信息

最终解决我的问题的
bin/rails

#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application',  __FILE__)
require_relative '../config/boot'
require 'rubygems'
require 'bundler/setup'
require 'rails/commands'

欢迎从发现这一点的人那里获得更多的见解

解决方案在我的情况下:-其他解决方案对我不起作用


在Rails目录中:

mv /usr/bin/rails /usr/bin/rails.old
bundle config --delete bin
rm -rf bin

# for rails 4.x:
rake rails:update:bin

# for rails 3.x:
bundle install --binstubs

# if you're using rbenv
rbenv rehash
rm -rf ~/.rbenv/plugins/{rbenv-bundle-exec,rbenv-gemset,bundler}
PATH=./bin:$PATH
还要确保将bin/rails添加到路径中,如:

mv /usr/bin/rails /usr/bin/rails.old
bundle config --delete bin
rm -rf bin

# for rails 4.x:
rake rails:update:bin

# for rails 3.x:
bundle install --binstubs

# if you're using rbenv
rbenv rehash
rm -rf ~/.rbenv/plugins/{rbenv-bundle-exec,rbenv-gemset,bundler}
PATH=./bin:$PATH

祝你好运。

当你更新ruby而不是相关的gems时,可能会出现此错误

要检查这是否是您的情况,请尝试在新的空目录中创建一个新的rails应用程序(确保RVM没有自动加载任何gemset)

如果这无法说明它找不到合适的“rails”,那么只需运行

gem update
并覆盖任何冲突的轨道

gem uninstall bundler
gem install bundler
卸载Bundler的所有版本,然后安装最新版本为我修复了它。我安装了多个版本的bundler,因此当我运行
bundle exec rails s
时,我认为使用了错误的bundler,这给了我警告消息


重新安装Bundler后,您可能需要生成新的存根,但我不必这样做。

这里也有同样的问题。Bundler 1.6.2、Rails 4.0.3、rbenv 0.4.0刚刚更新到Rails 4.0.5,它仍然给我带来了麻烦。如果运行建议的命令,您是否会遇到与我在文章末尾指出的相同的绑定器错误?简单修复:删除bin后,我必须运行
bundle exec rake rails:update:bin
。/*我正在使用Spring。这两个都不适合我。但是,rspec核心的
包确实起了作用。我很困惑。如此多的binstub选项。使用这些方法创建的binstub“消除了错误”,代价是失去了使用spring binstubs的速度优势。不值得。@nilbus这可能会让你感兴趣(我觉得spring已经死了):我从来没有遇到过他遇到的任何问题。这是唯一对我有效的方法。必须执行最后一个命令:
PATH=./bin:$PATH
我继续执行,并对我的bash_配置文件进行了此更改。这似乎不是最好的解决方案,但它消除了烦人的消息。@NewUserName我很高兴它解决了您的问题。使用这些方法创建的binstubs“消除了错误”,代价是失去了使用spring binstubs的速度优势。不值得。@nilbus你是什么意思?我更喜欢这种方法在每个目录的基础上将/bin加载到路径中/cc@TheLonelyGhost