Rails的bundle install会导致覆盖我们所有的bin目录内容

at.*_*at. 3 ruby ruby-on-rails heroku ruby-on-rails-4 ruby-on-rails-4.2

我们的一个Rails程序员一直搞乱我们的bin目录.他会跑bundle install,由于某种原因在bin目录中的脚本填满了我们几乎所有的宝石和5名的脚本,我们通常有有(bundle,rails,rake,setup,spring)得到覆盖.然后我们尝试做类似的事情heroku run console并获得一堆关于坏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')
Run Code Online (Sandbox Code Playgroud)

知道发生了什么以及如何阻止这种情况?

inf*_*sed 9

运行bundle --binstubs一次将创建一个捆绑器配置文件,.bundle/config其中包含一个条目,告诉bundler每次运行捆绑器时都要安装binstub.让开发人员编辑.bundle/config和/或~/.bundle/config删除此行:

BUNDLE_BIN: bin
Run Code Online (Sandbox Code Playgroud)

Bundler还有一种内置的方法来删除该配置项:

bundle config --delete bin
Run Code Online (Sandbox Code Playgroud)

完成后,您可以让Rails更新binstubs:

rake rails:update:bin
Run Code Online (Sandbox Code Playgroud)