[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ignoring RUBYOPT ?

Erik Veenstra

1/16/2005 8:31:00 PM


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.

3 Answers

Erik Veenstra

1/17/2005 8:29:00 PM

0

> 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.

Aredridel

1/17/2005 9:25:00 PM

0

On Tue, 18 Jan 2005 05:31:06 +0900, Erik Veenstra
<google@erikveen.dds.nl> wrote:
> > 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?
>

I don't think that's supposed to be solvable ... safe can only be
raised, not lowered.


Erik Veenstra

1/18/2005 11:10:00 AM

0

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/...
[2] http://www.erikveen.dds.nl/rubyscript2exe/...

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

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]
----------------------------------------------------------------