spring icon indicating copy to clipboard operation
spring copied to clipboard

Spring ignores ~/.irbrc and ./.rbenv-vars

Open exchgr opened this issue 10 years ago • 3 comments

Whether I run rails c (with spring binstubs installed) or bundle exec rails c, the console successfully connects to spring. However, it fails to load ~/.irbrc (wherein I enable command history) or ./.rbenv-vars (wherein I set an alternate Gemfile using the BUNDLE_GEMFILE variable).

This causes a few problems. In my alternate Gemfile, I specify gems that the rest of the team I work with wouldn't want cluttering up their machines, such as rb-readline, which fixes a number of issues with vim keybindings on the command line. I also use Fuubar, an alternate rspec formatter, and running rspec through spring fails to load it. Not to mention the issue with command history, which is to say that I have none.

exchgr avatar Jan 15 '15 16:01 exchgr

As a bandaid, I've done this for now: https://gist.github.com/exchgr/ed0d8c575b494ca89821

exchgr avatar Jan 15 '15 21:01 exchgr

I have similar issue:

  • using alternate Gemfile: Gemfile.local
  • with spring gem
    • when running BUNDLE_GEMFILE=Gemfile.local bundle exec rails console BUNDLE_GEMFILE is reset to Gemfile, thus I'm NOT able to use gems listed in Gemfile.local
    • when running BUNDLE_GEMFILE=Gemfile.local bundle exec rails server BUNDLE_GEMFILE variable is properly set to Gemfile.local and I can use gems listed in Gemfile.local
  • without spring gem
    • running both BUNDLE_GEMFILE=Gemfile.local bundle exec rails console and BUNDLE_GEMFILE=Gemfile.local bundle exec rails server properly set BUNDLE_GEMFILE variable and I can use gems listed in Gemfile.local

In this case workaround is to put following line in your ~/.spring.rb:

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

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

just in case Google brought you here, you might have the same problem I did when I found this: as of Rails 6, Rails uses pry, not IRB, under the hood, so your ~/.irbrc should actually be a ~/.pryrc instead.

gilesbowkett avatar Sep 22 '20 19:09 gilesbowkett