file-iomacruby

macruby open() not working


The following example is, of course, not my entire app. I have provided the part of it that throws an error:

#!/usr/local/bin/macruby

require 'open-uri'
framework 'ScriptingBridge'

system "mkdir -p ~/.myApp"
system "cp ~/Desktop/image.png ~/.myApp/image.png"

var = open('~/.myApp/image.png', 'w')

The error is:

open: No such file or directory - open() failed (Errno::ENOENT)

Am I missing a library or something?


Solution

  • I am not sure why but if you provide the path without using "~" it works.