Hello Racket community!
I'm trying to use namespace-require, but the executable seems to fail to look up the module, while commandline racket can run it normally. This is the minimal example:
First install the test-pkg package by running raco pkg install in the test-pkg directory.
Then running racket test.rkt normally outputs Hello. But running an executable generated by raco exe results in an error:
$ raco exe test.rkt && ./test
standard-module-name-resolver: collection not found
for module path: test-pkg/lib
collection: "test-pkg"
in collection directories:
context...:
.../test-pkg/test.rkt:3:2
body of '|#%mzc:test(main)|
body of top-level
I have found the last paragraph of 6.1.5 Module References Within a Collection mentioned a similar case, but I think I correctly used collection path (test-pkg/lib) instead of relative-path. What can I do?
Thanks for your reply! module-path-index-resolve really solved the problem.
I have tried resolve-module-path before, but it failed. I'm feeling that the module system is really intricate, and there are so many variants (and different phase levels maybe). I still need to figure out what all that means. Again thank you very much!
In the version without define-runtime-module-path-index, have you tried using ++lib when building the executable?
Using namespace-require seems like it would have the same kinds of issues that dynamic-require does in terms of needing ++lib/++lang to make sure raco exe embeds references to modules that otherwise appear unused.
IOW: raco exe test.rkt has no idea that it should bundle up lib.rkt; the racket/runtime-path collection cooperates with the executable and distribution builders to signal that, but you can also pass ++lib/++lang.