An update to my command line REPL adventures:

I'm still unable to get a working REPL, even when adding more and more 
information to raco exe/distribute. Here's my latest attempt:

raco exe ++lang foo ++lang racket/base ++lang racket ++lang brag ++lib 
racket ++lib racket/base foo.rkt

I've even taken to copying the entire Racket collects directory (!) based 
on the idea that the built-in executable is potentially looking for all 
sorts of things. Thus, after my raco exe and raco distribute invocations, 
I've got a build directory that looks like this:

$ ls /tmp/dist/lib/plt/foo/collects
acks
db
file
json
openssl
racket
realm
setup
xml
compiler
dynext
info
launcher
pkg
raco
foo # my package; everything else is standard Racket
syntax
data
ffi
info-domain
net
planet
reader
s-exp
version

In other words, I'm not only embedding a bunch of stuff into the generated 
executable, but making a ton of source code available, too. This all looks 
terribly excessive, and probably it is, but I've thrown all this stuff in 
out of desperation because I'm trying to ensure that racket/base can be 
used as lang via `namespace-require`.  Nonetheless, I still get a 
module-not-found error:

````
instantiate: unknown module
  module name: #<resolved-module-path:(submod '#%embedded:racket/base: 
reader)>
  context...:
   raise-arguments-error
   namespace-module-instantiate!96
   for-loop
   for-loop
   run-module-instance!125
   do-dynamic-require5
   read*14
   thunk_11
   dynamic-wind
   default-load-handler
   standard-module-name-resolver
   module-path-index-resolve5
   perform-require!78
  
 /var/folders/rx/lzgw7dzs0fqc1c7q1bv790_h0000gn/T/tmp.FrRgf7Mu/foo.rkt:64:0: 
run-repl
   call-with-values
   body of '|#%mzc:foo(main)|
````

Any idea what might be going on?

On Wednesday, September 25, 2019 at 7:37:41 AM UTC+2, Jesse Alama wrote:
>
> I'm working on building a standalone executable for a #lang that can be 
> used in two ways:
>
> 1. foo awesome.foo: execute file awesome.foo, which is written in #lang foo
>
> 2. foo (no arguments): fire up a REPL. Expressions are to be written in 
> the foo language.
>
> I can get (1) to work, after wrestling with raco exe (using ++lang) and 
> raco distribute (using ++collects-copy). An invocation that works for me is:
>
> ### begin script snippet
>
> raco exe ++lang foo ++lang racket/base ++lang brag foo.rkt
>
> # copy the source code of foo into collects/foo
> mkdir -p collects/foo
>
> find . -mindepth 1 -maxdepth 1 -name '*.rkt' -exec cp {} collects/foo ';'
>
> raco distribute ++collects-copy collects dist foo
>
> ### end script snippet
>
> This works for making a standalone executable that can exectute foo 
> programs specified on the command line, but doesn't work for a REPL. The 
> difficulty seems to be the `namespace-require` part of `run-repl`, defined 
> like this:
>
> ````
> (define (run-repl)
>   (parameterize ([current-namespace (make-base-empty-namespace)])
>     (namespace-require 'foo/expander)
>     (read-eval-print-loop)))
> ````
>
> When I invoke the executable with no arguments, `run-repl` gets called. 
> But this leads to:
>
> ````
> standard-module-name-resolver: collection not found
>   for module path: racket/base/lang/reader
>   collection: "racket/base/lang"
> ````
>
> expander.rkt in foo is written in racket/base, so I suppose that's what 
> triggers the issue.
>
> My question, crudely put, is: How do I "embed" racket/base so that I can 
> use `namespace-require` as seen in `run-repl`? (I assume namespace-require 
> is what I need; if that's wrong, please do correct me.) It appears that 
> ++lang racket/base bit in raco exe isn't enough. A related question about 
> raco exe is: if racket/base isn't available, what *is* available?
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/10939b31-6967-4851-ac42-9b9241ae8efd%40googlegroups.com.

Reply via email to