Guard 2.10.3 exits when Guardfile is changed
Just like you create binstubs, you can have a bin/guard
file that reloads automatically.
Just download this gist as bin/guard
.
Run Guard with this shell one-liner:
while bundle exec guard; echo "Restarting guard..."; do echo; done
And now, every time you change the file, Guard exits and gets restarted by the shell script. The extra echo
in the while condition is needed as otherwise Guard exits with a non-zero status, breaking the loop.
Note: Ctrl-D will no longer close Guard. You can use Ctrl-C to exit Guard.
100% bullet proof, as opposed to how reevaluating was implemented up till now.
If guard isn't responding to changes to your Guardfile - you may need to move you Guardfile
to another directory, and symlink it.
Why so?
Since the MacOS driver pretty much can watch only recursively, you can either:
- watch everything
- or watch given directories (and their contents, recursively), but without the top directory
Since option 1 is bad for big projects, the solution is using the directories
statement. But if you can't then watch the top directory, you can't watch the Guardfile
, the Gemfile
, etc.
So the solution to this new problem (can't use directories
and watch Guardfile
at the same time), is to put Guardfile
in a subdir (e.g. config
), watch that directory, and symlink it back.
For more info see: Optimizing for large projects
Supporting the feature was a maintenance nightmare (kind of like implementing fork() in pure Ruby in an app that heavily relies on global state - and there was always something broken).
So sorry for removing this feature - it kept the project from making any progress and we decided that with the above workarounds, it wasn't a show-stopper. But the gain was massive...
This wiki and the Guard README document contain a lot of information, please take your time and read these instructions carefully.
If you run into any trouble, you may start by understanding how Guard works.
We provide detailed changes for each Guard release.
Be sure to read the CONTRIBUTING guidelines before reporting a new Guard issue or open a pull request.
If you have any questions about the Guard usage or want to share some information with the Guard community, please go to one of the following places:
- Google+ community
- Google group
- StackOverflow
- IRC channel
#guard
(irc.freenode.net) for chatting