È possibile compilare uno script ruby in un file .exe su Windows? Ho cercato dappertutto e ho provato la seguente (Sembrava RubyScript2EXE, Scarpe e Crate tutti sembravano morti o abbandonati.):Compilare script in rubino in exe?
sto usando Rubino 1.8.7 su Windows 7 Ultimate (64bit.) da un sistema pulito faccio questo:
- Installare RubyInstaller 1.8.7-P358 da rubyinstaller.org 0.123.516,41 mila
- gem install watir
- gem install ocra
- clone git git: //github.com/snaury/exerb-mingw.git
- cd exerb-MinGW
- rubino setup.rb
ho un abbastanza semplice script che fa questo:
require 'rubygems'
require 'watir'
browser = Watir::Browser.new
browser.goto 'http://slashdot.org'
Quando eseguo Ocra non ho ricevuto alcun messaggio di errore, e non succede nulla:
ocra --output test.exe test.rb
=== Loading script to check dependencies
Exerb sembra una soluzione migliore in quanto si compila RBC, e lo fa in realtà fare qualcosa:
ruby -r exerb/mkexy test.rb
# Window pops up and after I close it it writes out test.exy
C:\Users\jonathan\dev\Citation>exerb test.exy
C:/Ruby187/lib/ruby/site_ruby/1.8/exerb/recipe.rb:146:in `add_file_entry': test.
exy: no such file -- C:/Ruby187/lib/ruby/gems/1.8/gems/win32-api-1.4.8-x86-mingw32/lib/win32/ruby18/win32/api.so (RuntimeError)
from C:/Ruby187/lib/ruby/site_ruby/1.8/exerb/recipe.rb:86:in `create_archive'
from C:/Ruby187/lib/ruby/site_ruby/1.8/exerb/recipe.rb:85:in `each'
from C:/Ruby187/lib/ruby/site_ruby/1.8/exerb/recipe.rb:85:in `create_archive'
from C:/Ruby187/bin/exerb.bat:67:in `main'
from C:/Ruby187/bin/exerb.bat:196
Quindi non riesce a trovare win32/api.so. Quando guardo in C: /Ruby187/lib/ruby/site_ruby/1.8/exerb/recipe.rb sembra che le gemme non sono nel percorso di ricerca:
DIR: C:/Users/jonathan/dev/Citation
DIR: C:/Ruby187/lib/ruby/site_ruby/1.8
DIR: C:/Ruby187/lib/ruby/site_ruby/1.8/i386-msvcrt
DIR: C:/Ruby187/lib/ruby/site_ruby
DIR: C:/Ruby187/lib/ruby/vendor_ruby/1.8
DIR: C:/Ruby187/lib/ruby/vendor_ruby/1.8/i386-msvcrt
DIR: C:/Ruby187/lib/ruby/vendor_ruby
DIR: C:/Ruby187/lib/ruby/1.8
DIR: C:/Ruby187/lib/ruby/1.8/i386-mingw32
DIR: .
Così, dopo aver scavato in giro ho scoperto che è possibile aggiungere percorsi di ricerca nel file exy in questo modo:
path:
- C:/Ruby187/lib/ruby/gems/
- C:/Ruby187/lib/ruby/gems/1.8
- C:/Ruby187/lib/ruby/gems/1.8/gems
Dopo questo lo fa mostrare questi percorsi in search_path, ma mi dà ancora lo stesso errore. Ovviamente ci deve essere un modo per ottenere percorsi di rubygems da includere nell'exy?
Quindi, come fa qualcuno a costruire un file .exe su Windows in questi giorni?
Ho fatto dei progressi con Exerb, ho scoperto che è possibile eseguire mkexy con l'opzione -rrubygems per farlo entrare. E questo funziona GRANDE per la maggior parte dei progetti ruby. L'ho provato per alcuni script ruby che utilizzano un numero di librerie diverse senza problemi. Ad esempio:
mkexy -rrubygems test.rb
exerb test.exy
test.exe === WORKS!
Sfortunatamente, non funziona per watir. Quando eseguo un exe costruito con watir ottengo il seguente: valore di
s4t-utils/claims.rb:24:in `user_is_bewildered': Error in the default values: :br
di owser deve essere uno dei 'safari', 'firefox', o 'cioe', e '' non ha un aspetto r ight .(StandardError)
Forse si può provare questo: http://johnallen.us/?p=278 –
Hai visto una console generata da Ocra? Se hai compilato un file .rb anziché un file .rbw, dovresti averne visto uno. –
In realtà non ho visto niente, nessuna finestra, niente. Forse è spuntato il messaggio di errore menzionato nel link johnallen.us e poi è morto? Sperimenterò di più con ocra domani e aggiornerò questa domanda. –