0

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?

tshepang
  • 12,111
  • 21
  • 91
  • 136
dejay
  • 758
  • 2
  • 6
  • 18

2 Answers2

0

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

kwicher
  • 2,092
  • 1
  • 19
  • 28
  • I realized that too. I was wondering if there was someway to work around that, though. It is quite annoying. Thanks for helping! – dejay Jun 01 '12 at 23:04
0

This should work: File.open File.expand_path('~/image.png'), 'w'

blandw
  • 36
  • 1
  • 2