From: kyonides Date: 2022-10-27T17:47:30+00:00 Subject: [ruby-core:110524] [Ruby master Bug#19086] Dir#entries and Dir#glob fail in stand-alone CRuby app Issue #19086 has been updated by kyonides (Edwin Acu��a). mame (Yusuke Endoh) wrote in #note-1: > I guess you need to call `ruby_init` and `ruby_options` instead of `ruby_setup`. I think `Dir.glob` is defined in `ruby_options`. =_=�� I was hoping the solution wouldn't be that simple because it would mean that I was making a mistake by using ruby_setup instead or the ruby_init and ruby_options functions. Curiously, ruby_options does load Dir.entries and Dir.glob so this report can be closed safely now. Thanks for the heads up, Endoh! ---------------------------------------- Bug #19086: Dir#entries and Dir#glob fail in stand-alone CRuby app https://bugs.ruby-lang.org/issues/19086#change-99848 * Author: kyonides (Edwin Acu��a) * Status: Open * Priority: Normal * ruby -v: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- Whenever I call Dir.entries or Dir.glob using an app compiled against Ruby 3.0 on Ubuntu 22.04, I expect to get a list of files or directories present there. This does not happen if you are calling it from a stand-alone app like the one I attached to this bug report. It does not matter if I call it by evaluating some C string or by depending on a rb_funcall, it will certainly fail to do anything. First Result: the application will segfault in no time. Second Result: if calling rb_eval_string_protect function to evaluate the string, calling Dir#entries or Dir#glob methods, you get the following output. NoMethodError raised! undefined method `glob' for Dir:Class TypeError raised! wrong argument type File (expected dir) eval:1:in `entries' Dir#entries treats the tmp directory that the test code had created via Dir#mkdir as a file... I have also tried compiling the same CRuby app against Ruby 2.7 and everything works fine. I suspect that the introduction of Primitive is causing this issue. CRuby 3.0 is unable to find the context of Primitive or any default Ruby script installed on the target machine that may call Primitive at some point. The expected result should be to be able to get both methods return all of the files and directories as it used to do in earlier versions of Ruby. ---Files-------------------------------- main.cpp (2.12 KB) ruby30 output.txt (464 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: