Ignoring RUBYOPT ?


E

Erik Veenstra

How can I let Ruby ignore RUBYOPT?

Both -T1 and unsetting the environment variable aren't possible
in my situation. I don't want the rest of the script to run in
safe mode 1 and I don't have control of the environment...

gegroet,
Erik V.
 
Ad

Advertisements

E

Erik Veenstra

How can I let Ruby ignore RUBYOPT?
Both -T1 and unsetting the environment variable aren't
possible in my situation. I don't want the rest of the script
to run in safe mode 1 and I don't have control of the
environment...

No solutions? Anybody?

gegroet,
Erik V.
 
Ad

Advertisements

E

Erik Veenstra

The problem with RUBYOPT is fixed! Or rather worked-around...

I had to add "-T1" to the command line, so ruby.exe didn't
parse RUBYOPT, while the application itself still had to run in
safe mode 0. Conflicting requirements. The trick is to put
"-T1" on the *right place* on the command line: *After* the
real work is done, but *before* the main script ruby.exe is
going to run. I came up with this:

ruby -r ./bootstrap -T1 empty.rb ./realstuff.rb

This bootstrap.rb simply loads ARGV.shift (=realstuff.rb). This
means that the real stuff is done in safe mode 0. After
realstuff.rb and bootstrap.rb have ended, ruby.exe switches to
safe mode 1, skips RUBYOPT and runs the main script, which is
empty. Voila!

Thanks for your ideas. All of you. All ideas and thoughts
together put my thoughts in the right direction. Thanks.

Oh, by the way... Why is my situation so restrictive? Well, the
above contructed command line is run by a little Pascal
program, EEE [1], which is the bootstrapping part of
RubyScript2Exe [2]. EEE creates an environment (Ruby + App),
executes the command line in this environment and finally
deletes all temporary files. Because RubyScript2Exe is run on a
lot of Ruby installations, I couldn't use a customized Ruby and
I couldn't control the environment. The executable created by
RubyScript2Exe is run on machines which are even less
controled: The ones of the customers...

Please send me reports of all bugs and glitches you find when
using RubyScript2Exe. Propositions for enhancements are
welcome, too. This helps us to make our software better.

This thread indicates how complex a tool like RubyScript2Exe
can be(come). Someday, I reach a point where it's not possible
to do everything myself. I need you, guys!

Thanks a lot!

gegroet,
Erik V.

[1] http://www.erikveen.dds.nl/eee/index.html
[2] http://www.erikveen.dds.nl/rubyscript2exe/index.html

----------------------------------------------------------------

Show the environment:

s:> echo %RUBYOPT%
rubygems

----------------------------------------------------------------

Show the scripts:

s:> type bootstrap.rb
p ["BOOTSTRAP", $SAFE]
script = ARGV.shift
$0 = script
load(script)

s:> type empty.rb
p ["EMPTY", $SAFE]

s:> type realstuff.rb
p ["REALSTUFF", $SAFE]
p $0
p ARGV

----------------------------------------------------------------

Show the original problem (with RUBYOPT):

s:> ruby ./realstuff.rb 'a b' c
L:\\prog\\ruby-mingw32\\usr\\local\bin\\ruby: No such file to load --
ubygems
(LoadError)

----------------------------------------------------------------

Show the solution:

s:> ruby -r ./bootstrap -T1 empty.rb ./realstuff.rb 'a b' c
["BOOTSTRAP", 0]
["REALSTUFF", 0]
"./realstuff.rb"
["a b", "c"]
["EMPTY", 1]
----------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top