When the current working directory does not exist, loading the shell prompt (_e.g.,_ by hitting <Enter>) causes the following error to appear:
direnv: error LoadConfig() Getwd failed: "getwd: no such file or directory"
$ mkdir foo
$ cd foo
$ rmdir $(pwd)
direnv: error LoadConfig() Getwd failed: "getwd: no such file or directory"
what is the behaviour that you would expect?
Whoops, good point.
As a general principle, I would expect to see an error message only when a program has failed to perform one of its expected functions. Since I don't expect direnv to do anything in a non-existent directory, I would expect to see no error message at all.
I agree, direnv shouldn't be doing anything (from a user's point of view) in a directory that doesn't exist.
I'd suggest:
I'd suggest:
1. Store the CWD when running the hook (initialize to /?) 2. If the stored CWD directory doesn't exist next time, exit early
No need to store anything. Simply catch this error or check for existence beforehand.
Most helpful comment
Whoops, good point.
As a general principle, I would expect to see an error message only when a program has failed to perform one of its expected functions. Since I don't expect direnv to do anything in a non-existent directory, I would expect to see no error message at all.