This might be better suited for "Internals", but being my first post to this forum...
One particular issue that exists is that of being able to ffi-lib
dynamic libraries that have been installed by raco
. This is especially frustrating on MacOS for reasons I'll go into.
The ffi-lib
function appears to use dlopen
to find libraries. This is great, except that if I have a system version of a library installed and use raco
to install another version of the same library for my super-awesome-package, when I call ffi-lib
(during development) it'll load the system-installed version, which can cause problems/conflicts.
On MacOS this can be extremely problematic for DrRacket, as dlopen
uses environment variables for searching where it should load libraries: LD_LIBRARY_PATH
, DYLD_LIBRARY_PATH
, ... However, all of these variables are protected, and unset whenever a desktop application is launched. For example:
$ launchctl setenv FOO bar
$ launchctl setenv DYLD_LIBRARY_PATH /opt/homebrew/lib
// launch DrRacket
(getenv "FOO") ; "bar"
(getenv "DYLD_LIBRARY_PATH") ; #f
So I - as a MacOS user - have no control over where DrRacket searches for dynamic libraries I'm trying to load. It's 100% controlled by the program running via runtime search paths (i.e., @loader_path
, @executable_path
, and @rpath
).
I can install dynamic libraries myself - for my packages - using raco
, and they install to $HOME/Library/Racket/8.17/lib
(on MacOS, and I assume another similarly suitable place on Windows/Linux), but racket/DrRacket never looks for them there at any time other than compilation and adding them to the final, distributed program.
I think it would phenominally awesome if Racket (and DrRacket) first attempted to load dynamic libraries from the raco
installed set of dynamic libraries, and then - if not found - could fall-back to the system paths.
I believe this would fix both DrRacket on MacOS and the global issue of loading dynamic libraries from the system before package-installed versions.
And if there's currently an existing workaround (or setting) for this that I haven't found yet, please let me know.