spring
spring copied to clipboard
BUNDLE_PATH environment variable ignored causing all commands to fail
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.
I'm having a similar issue declaring a different BUNDLE_GEMFILE
#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')
Is https://github.com/rails/spring/issues/374 possibly a duplicate of this?
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?
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.
It further seems that any environment variable in the shell is not propagated into spring.
This PR seems like it ought to fix the problem: https://github.com/rails/spring/pull/546
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 are you using this in Docker? Do you maybe have an error output? I have a feeling we're hitting the same thing.
@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.