no such file or directory

Sorry, brief interlude here for something that keeps getting me. I get this error on getcwd all the time when doing programmatic git things. This is how you recreate it:

Make a directory, change to it and open a console:

cd /tmp
mkdir foo
cd foo
irb

Check the pwd:

$ irb
irb(main):001:0> Dir.pwd
=> "/private/tmp/foo"

Now, in a separate terminal, delete that foo folder (leaving irb open)

rm -rf /tmp/foo

Now, back in your console, get the pwd again:

irb(main):002:0> Dir.pwd
Errno::ENOENT: No such file or directory - getcwd
	from (irb):2:in `pwd'
	from (irb):2

So if you are getting this in your code, it is because you are deleting a folder out from under yourself (which tends to happen a lot when testing).