Menu

#6 Module loading bug

open
nobody
None
5
2007-04-23
2007-04-23
Anonymous
No

/rb exec require 'gtk2'

Ruby error executing hook 'rb': can't convert false into String
/usr/lib/ruby/site_ruby/1.8/gtk2.rb:13:in `init'
/usr/lib/ruby/site_ruby/1.8/gtk2.rb:13
(/rb exec):1:in `require'
(/rb exec):1:in `rb_command_exec'
(eval):461:in `eval'
(eval):519:in `rb_command_exec'
(eval):461:in `rb_command_hook'
(eval):212:in `call'
(eval):212:in `process_command_hook'
(eval):228:in `process_hook'
(eval):225:in `each'
(eval):225:in `process_hook'
(eval):212:in `process_command_hook'

/rb exec require 'gtk2'

The second time it executes cleanly and works.

xchat-ruby-plugin.rb

def module_load( file )
$LOAD_PATH.dup.unshift( "" ).each do |path|
f = path + ( path.length > 0 ? "/" : "" ) + file
if File.exist? f
File.open( f, "r" ) do |fh|
lines = fh.readlines.join
module_eval lines
end
return true
end
end
raise "could not load \"#{file}\""
end

Removing either of these two lines:
lines = fh.readlines.join
module_eval lines
stops the error but stops the file from loading.

The "false" may be coming from elsewhere as I have tried checking for lines == false

Discussion


Log in to post a comment.