Bug #19086
closedDir#entries and Dir#glob fail in stand-alone CRuby app
Description
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