help, weird global variable + load problem

P

Pascal Meunier

We have a script starting with:

#!/usr/bin/ruby -w
require 'cgi'
cgi=CGI.new("html4")
begin
$load_path = nil
load 'conf.rb'
load 'create_vars.rb'
(...)

Which generates the error:

/create_vars.rb:1:in `load': string contains null byte (ArgumentError)

This is the line in create_vars.rb that generates the error:

load $load_path + 'lib/name_string.rb'

The global variable $load_path is assigned a value in conf.rb. The error is
inexplicably fixed by inserting arbitrary code between the two load
commands:

require 'cgi'
cgi=CGI.new("html4")
begin
$load_path = nil
load 'conf.rb'
b=cgi
load 'create_vars.rb'

where "b=cgi" can be *any* code you think of; it magically makes the error
go away and restores the value of $load_path that is assigned in conf.rb.


Other details:
This code runs on an Athlon-64 with Gentoo Linux. Programming in Ruby has
been a lot of fun ever since we ditched mod-ruby (restarting Apache every
time we change a class definition? Geez). However, getting errors like
this one gives me a headache.

Any ideas, besides leaving the bogus "b=cgi" code in?

thanks,
Pascal
 

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

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top