Skip to content
This repository

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

Closed
jimryan opened this Issue · 6 comments

4 participants

Jim Ryan Michael Kessler Thibaud Guillaume-Gentil David Rodríguez
Jim Ryan

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.

Michael Kessler netzpirat closed this issue from a commit
Michael Kessler 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.
dda6047
Michael Kessler
Owner

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.

Jim Ryan

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!

Thibaud Guillaume-Gentil
Owner

@jimryan thanks for your kind words!

David Rodríguez

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!

Michael Kessler
Owner
David Rodríguez

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
Something went wrong with that request. Please try again.