All the resources about packaging ruby applications seem to be for bundler/gems, but I don’t think that can be used for the C API. My issue is that when I use mkDerivation to compile a C application that calls ruby code (eg. using rb_eval_string_protect) and that ruby code tries to load a native library it is unable to find it and crashes.
I’ve checked the specific library (zlib) is enabled in Nix’s ruby package, and I’m able to load it in irb when I load ruby in a nix-shell. At runtime, I’ve determined that in the built application ruby’s LOAD_PATH variable only contains the working dir, and the RUBYLIB and LD_LIBRARY_PATH environment variables are empty, whereas loading ruby in a nix-shell they are set correctly.
I tried copying ruby’s setup-hook, but that didn’t help, and I’ve not managed to get it working with a wrapper setting the vars to the output of lib.makeLibraryPath either. The only thing I can think of is that possibly this might require a static ruby?
I’m very interested to hear if there’s a proper way to inherit library paths, or any other means to make ruby’s default system libraries available to programs that interface with the Ruby C API (obviously I’ve already tried simply adding them to the build inputs).