small medium large xlarge

08 Aug 2012, 22:46
Stephen E Riley (10 posts)

This is a noob question. I’m going through your book and was getting an file and/or directory not found error when I used the todo default “~/.todo.txt for the -f flag. I was trying to open the file with mode ‘a+’

When I changed the default to ENV[‘HOME’] + “/.todo.txt, it opened ok.

I am using OSX 10.8 and ruby 1.93p194 and gli 1.6.0.

Is there a setting I haven’t made or have made that affects the use of ‘~’ to stand for the home directory. I can use ‘~/whatever’ from the command-line successfully


08 Aug 2012, 22:48
Stephen E Riley (10 posts)

for some reason, I’m not able to use the tilde representation in this text. Sorry

12 Aug 2012, 21:34
David Copeland (366 posts)

Hmm, I thought that you could use the tilde syntax by itself, but it seems that the @File@ operations won’t work. If you use @File.expand_path@ it will, though:"~/.todo.txt")) do |file|
  # ..

Or, better:

desc "Path to the todo file"
arg_name "todo_file"
default_value File.expand_path("~/.todo.txt")
flag :f

Sorry for the confusion; there must be some code somewhere that does that that I was aware of, since the code all works/passes tests. Could be the faking out of the home directory masked it, though…

You must be logged in to comment