[activate.tmpl.sh] Gracefully handle when the bin dir disappears
This PR updates update_hermit_env to handle the case when the bin directory disappears:
Before every command, hermit's update_hermit_env function interacts with ${HERMIT_ENV}/bin a few times (eg checking to see if it was modified, executing the ${HERMIT_ENV}/bin/hermit function, etc.) However, if either of these are missing, it causes noisy errors:
hm🐚 /tmp/hm % mv bin bin2
usage: date [-jnRu] [-I[date|hours|minutes|seconds]] [-f input_fmt]
[-r filename|seconds] [-v[+|-]val[y|m|w|d|H|M|S]]
[[[[mm]dd]HH]MM[[cc]yy][.SS] | new_date] [+output_fmt]
update_hermit_env:4: no such file or directory: /tmp/hm/bin/hermit
update_hermit_env:5: no such file or directory: /tmp/hm/bin/hermit
update_hermit_env:6: no such file or directory: /tmp/hm/bin/hermit
hm🐚 /tmp/hm %
While during normal usage, the bin directory shouldn't disappear, I've encountered it multiple times personally (eg swapping between different git branches, before and after hermit as added to the repo, or even just accidentally moving the bin dir.)
This PR fixes this by checking to see if ${HERMIT_ENV}/bin/hermit exists before running the rest of update_hermit_env; If it doesn't it calls deactivate-hermit to disable hermit. However, _hermit_deactivate (called by deactivate-hermit) also uses ${HERMIT_ENV}/bin/hermit as well. So this also had to be changed to default to the system-wide hermit if needed
I think we talked about this in Slack, but would you mind adding an integration test for this to integration/integration_test.go?