Fails with Ocra
bil-bas opened this issue · 5 comments
Ocra always forces the loading of all autoload files, to ensure that they are included in the Windows executable that it creates. Although the way you use autoload is neat, it fails in this specific instance. I suggest checking the Ocra constant (it is defined only if Ocra is building an executable):
unless defined? Ocra autoload :Linux, 'clipboard/linux' autoload :Mac, 'clipboard/mac' end autoload :Windows, 'clipboard/windows' autoload :File, 'clipboard/file'
This patch works for me.
Hi Spooner,
thanks for this notice. I'll have a windows available in some days and will take a look at it.
That is great, thanks! As I said, I was able to patch it easily enough to avoid the issue, so there is no critical rush.
Since reporting, I have found out that I could use 'ocra --no-autoload' to prevent Ocra trying to madly load everything on the off-chance that it will be used at some point in the application (that is, that isn't auto-loaded at compile time), so ensuring that users know they can use this might be another option which works, but puts the onus on the developer and may cause failure with other gems that use autoload to delay loading files which are actually critical.
Hey, now I've got the windows ;). Can you please post the command (and ruby version) you used to package the gem?
I was specifically using Ruby 1.9.2 on Windows 7 x64 (sorry, I should have said this earlier).
Only needs a very simple application:
require 'clipboard'
puts Clipboard.paste
Works fine normally, of course, but with ocra, it tries to load all the autoloads:
ocra clipboard_test.rb
=== Loading script to check dependencies
...correctly prints out the contents of the clipboard here...
c:/ruby192/lib/ruby/gems/1.9.1/gems/clipboard-0.9.8/lib/clipboard/linux.rb:11:in
``': No such file or directory - which xclip (Errno::ENOENT)
from c:/ruby192/lib/ruby/gems/1.9.1/gems/clipboard-0.9.8/lib/clipboard/l
inux.rb:11:inmodule:Linux' from c:/ruby192/lib/ruby/gems/1.9.1/gems/clipboard-0.9.8/lib/clipboard/l inux.rb:5:in
<top (required)>''
As I said, using ocra --no-autoload
makes this work, so you might not see it as an issue that it is your responsibility to handle. I'll leave it with you!
Applied your patch with version 0.9.9. Thanks.