[ruby-talk:00199] Re: auto-loaded script?

From: Julian Fondren <julian@...>
Date: 1999-01-18 11:15:31 UTC
List: ruby-talk #199
> Could you tell me what exactly happened, i.e, show me your main.c,
> compilation messages from make, error messages from Ruby, please.
> 
> At first, I thought that was because rb_load_file() does not evaluate
> nor expand path.  You have to get the full path of the loading file by
> yourself.  For example,
> 
>    char path[256];
> 
>         :
>    snprintf(path, 256, "%s/.rubyrc", getenv("HOME"));
>    rb_load_file(path);
>         :
> 
> But error was happened in Ruby file.  I don't get what is happening.
> 
>                                                 matz.

main.c (aside from the commented portion at the top) is


=begin main.c

#include "ruby.h"

#ifdef DJGPP
unsigned int _stklen = 0x100000;
#endif

#ifdef __human68k__
int _stacksize = 131072;
#endif

int
main(argc, argv, envp)
    int argc;
    char **argv, **envp;
{
#if defined(NT)
    NtInitialize(&argc, &argv);
#endif

    ruby_init();
    ruby_options(argc, argv);
    rb_load_file("/usr/local/lib/ruby/rubyinit.rb");
    ruby_run();
}

=end main.c



/usr/local/lib/rubyinit.rb is


=begin /usr/local/lib/rubyinit.rb

## ruby init file

require "#{ENV['HOME']}/rubyrc.rb"

=end /usr/local/lib/rubyinit.rb



and the error is


=begin error
util.c:137: warning: mktemp() possibly used unsafely; consider using
mkstemp()
/home/julian/rubyrc:3: Unitialized constant Readline (NameError)
	from /usr/local/lib/ruby/rubyinit.rb:3
*** Error code 1

Stop in /usr/local/tmp/ruby-1.2.1.
=end

now, other than the silliness of putting a period on a statement which
gives a path (yuk), there is that this error is regarding a script in the
home directory of the compiling person, and that this script is something
that should NOT even be accessed by make or the compile! The earlier error
that /home/julian/.rubyrc did not exist (a false statement) was due to a
syntatic error in /usr/local/lib/ruby/rubyinit.rb -- but that file should
not have been read either - both are supposed to be read when ruby starts
up for the first time after I finish compiling it.

btw.. the syntax error was

require "#{ENV['HOME']/.rubyrc}"

see it? :-)

I think that the reading of those files may be due to miniruby's role in
compilation.. but that is mainly a guess.


I hope this helps.

In This Thread