Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails' bundle install causing all of our bin directory contents to be overridden

One of our Rails programmers keeps messing up our bin directory. He'll run bundle install and for some reason the bin directory fills up with scripts for almost all of our gems and the 5 scripts we normally have there (bundle, rails, rake, setup, spring) get overridden. We then try and do something like heroku run console and get a bunch of warning messages about bad bin files. But everything seems to work anyway.

Here's an example rails file that gets overridden:

#!/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')

any idea what's going on and how to stop this?

like image 668
at. Avatar asked Apr 06 '15 20:04

at.


People also ask

What is bundle install in Rails?

In Rails, bundler provides a constant environment for Ruby projects by tracking and installing suitable gems that are needed. It manages an application's dependencies through its entire life, across many machines, systematically and repeatably. To use bundler, you need to install it. gem install bundler.

How do I fix a run bundle to install missing gems?

Select Tools | Bundler | Install from the main menu. Open the Gemfile, place the caret at any highlighted gem missing in the project SDK and press Alt+Enter . Select Install missing gems using 'bundler' and press Enter .

Why bundle install is installing gems in vendor bundle?

In deployment, isolation is a more important default. In addition, the user deploying the application may not have permission to install gems to the system, or the web server may not have permission to read them. As a result, bundle install --deployment installs gems to the vendor/bundle directory in the application.

What bundle install does?

Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed. Bundler is an exit from dependency hell, and ensures that the gems you need are present in development, staging, and production. Starting work on a project is as simple as bundle install .


1 Answers

Running bundle --binstubs even once will create a bundler config file in .bundle/config with an entry that tells bundler to install binstubs each time bundler is run. Have the developer edit .bundle/config and/or ~/.bundle/config and remove this line:

BUNDLE_BIN: bin

Bundler also has a built in way to delete that configuration item:

bundle config --delete bin

Once you've done that, you can have Rails update the binstubs:

rake rails:update:bin
like image 73
infused Avatar answered Sep 28 '22 14:09

infused