我们的一位 Rails 程序员一直在搞乱我们的 bin
目录。他将运行 bundle install
并且出于某种原因,bin
目录填满了几乎所有我们的 gem 的脚本和我们通常在那里的 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')
知道发生了什么以及如何阻止它吗?
最佳答案
即使运行一次 bundle --binstubs
也会在 .bundle/config
中创建一个 bundler 配置文件,其中包含一个条目,告诉 bundler 在每次运行 bundler 时安装 binstubs。让开发人员编辑 .bundle/config
和/或 ~/.bundle/config
并删除此行:
BUNDLE_BIN: bin
Bundler 也有一个内置的方法来删除那个配置项:
bundle config --delete bin
完成后,您可以让 Rails 更新 binstubs:
rake rails:update:bin
关于ruby-on-rails - Rails 的 bundle install 导致我们所有的 bin 目录内容被覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29478783/