Loading the Rails env in your .pryrc breaks Guard #354

jimryan opened this Issue Oct 29, 2012 · 6 comments

4 participants


Now that Pry is our Guard interactor (PR #327), anyone who has followed the Pry wiki for using Pry with Rails without altering their Gemfile (https://github.com/pry/pry/wiki/Setting-up-Rails-or-Heroku-to-use-Pry#wiki-without_gemfile) will see Guard inexplicably die immediately prior to loading Pry.

This has to do with their ~/.pryrc loading the Rails environment. I haven't dug too deeply into the issue, but ultimately, we don't want the Rails environment to be loaded in Guard's Pry session.

I'm not sure what the best course of action is to solve this. I think it's still valuable to be able to load Rails in any pry session without an initializer or a plugin like pry-rails (consider the situation where only one developer on a team wants to use Pry), so I don't think "don't do that" is a sufficient answer. Fortunately, if anyone has copied and pasted the .pryrc snippet on the Pry wiki exactly, then loading Rails can be skipped with the ENV['SKIP_RAILS'] environment variable.

My current solution is to add: ENV['SKIP_RAILS'] = 'true' to my ~/.guard.rb file.

If that's the best solution, then it should probably be mentioned somewhere in Guard's docs. I'd be happy to provide any additional information if it's needed.

@netzpirat netzpirat added a commit that closed this issue Oct 30, 2012
@netzpirat netzpirat Ignore `~/.pryrc`. (Fixed #354)
Loading the Rails env in `~/.pryrc` breaks Guard, thus we're going to
ignore it, making `~/.guardrc` the only place to customize the Guard
pry session.
@netzpirat netzpirat closed this in dda6047 Oct 30, 2012

Thanks a lot for reporting. I disabled the loading of ~/.pryrc for Guard, so the normals Pry configuration is completely separated from the Guard Pry configuration.


Excellent! I think that makes the most sense.

Also, Guard has completely changed how I work and has become an invaluable addition to my toolchain. I can't thank you enough for it!

Guard member

@jimryan thanks for your kind words!


Hi! So is it not recommended to load rails in guard's pry console?

  • If yes, why? It would seem to me like a handy quick console to quickly investigate why a test is failing, for example.
  • If not, how can I actually do it without breaking guard?

Thanks a lot and congratulations for guard!


Thanks Michael!

The title of this issue made me think that loading rails in the guard console would break guard. But it actually seems to work! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment