spring icon indicating copy to clipboard operation
spring copied to clipboard

BUNDLE_PATH environment variable ignored causing all commands to fail

Open austinche opened this issue 11 years ago • 10 comments
trafficstars

I use the environment variable BUNDLE_PATH to set the gem directory. All spring commands then fail as if no gems are installed requesting bundle install to be run. What appears to be happening is application_manager.rb calls Bundler.with_clean_env which wipes out this environment variable, then the require "bundler/setup" line fails in spring/commands.rb. I can work around this by setting ENV['BUNDLE_PATH'] in ~/.spring.rb or by setting the bundle path in ~/.bundle/config but I would prefer to not use either of those files.

austinche avatar Jul 21 '14 21:07 austinche

I'm having a similar issue declaring a different BUNDLE_GEMFILE

arjes avatar Oct 06 '14 20:10 arjes

#374 In short: workaround for using different Gemfile (for example Gemfile.local) is to put this line in your ~/.spring.rb:

ENV['BUNDLE_GEMFILE']='Gemfile.local' if File.exist?('Gemfile.local')

Gee-Bee avatar Feb 18 '15 11:02 Gee-Bee

Is https://github.com/rails/spring/issues/374 possibly a duplicate of this?

exchgr avatar Feb 18 '15 16:02 exchgr

Ruby 2.3.0 Bundler 1.11.2

Given:

$GEM_HOME=/home/app/.rvm/gems/ruby-2.3.0 and $BUNDLE_PATH=/srv/bundle

I have created new rails app. Then cd into its folder. Then typed command bundle install. And then bundler installed all the gems from Gemfile to the /home/app/.rvm/gems/ruby-2.3.0 instead of /srv/bundle.

Is it kinda bug or something?

starkovv avatar Jan 09 '16 18:01 starkovv

I have the same problem with BUNDLE_PATH. The reason I'm setting it is to use inside docker without rebuilding the docker image on each Gemfile change, then when I try to run spring inside the docker container it can't find the gems in the custom BUNDLE_PATH.

filipegiusti avatar Apr 15 '16 20:04 filipegiusti

It further seems that any environment variable in the shell is not propagated into spring.

joallard avatar May 25 '17 18:05 joallard

This PR seems like it ought to fix the problem: https://github.com/rails/spring/pull/546

scytacki avatar Feb 22 '18 15:02 scytacki

Seems this is fixed in the main repo, but the fix hasn't been packaged and deployed as a gem. Despite the readme saying that it's not supported and won't work, I bundled from github and it seems to be humming along for me.

darkhelmet avatar Jan 31 '19 19:01 darkhelmet

@darkhelmet are you using this in Docker? Do you maybe have an error output? I have a feeling we're hitting the same thing.

bobbytables avatar Jan 31 '19 22:01 bobbytables

@bobbytables I added this:

gem 'spring', github: 'rails/spring'
gem 'spring-commands-rspec'

to my Gemfile, I run a docker-compose service with spring server as the command (building the same image as the app)and life is good. We haverspecdefined as a bash function that doesdocker-compose exec spring spring rspec ...` and everything works great.

The latest version of the spring gem on rubygems.org doesn't have #546 in it, which I suspect is the reason it was causing me problems.

I don't have any error output.

darkhelmet avatar Feb 01 '19 18:02 darkhelmet