Ruby: opening files relative to home directory
- by Peter
In Ruby, the following fails with Errno::ENOENT: No such file or directory, even if the file exists:
open('~/some_file')
However, you can do this:
open(File.expand_path('~/some_file'))
Two questions:
Why doesn't open process the tilde as pointing to the home directory?
Is there a slicker way than using
File.expand_path?