macruby open() not working
Frage
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?
Lösung
I am not sure why but if you provide the path without using "~" it works.
Andere Tipps
This should work:
File.open File.expand_path('~/image.png'), 'w'
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow