Jay McCarthy writes:

> I feel like I might not understand what you want, but it feels like
> you just want to use `make-module-evaluator` from `racket/sandbox`:
>
> ```
> #lang racket/base
> (require racket/sandbox)
>
> (define (read-script s)
>   (((make-module-evaluator s) 'script) 5))
>
> (module+ test
>   (read-script
>    "#lang racket/base
>     (provide script)
>     (define (script x) (add1 x))")
>   (read-script
>    "#lang typed/racket/base
>     (provide script)
>     (: script (-> Number Number))
>     (define (script x) (add1 x))"))
> ```
>
> You may want to set the `#:language` argument to control the language.
> And you will also want to set `sandbox-namespace-specs` to link up
> your internal data-structure providing modules so you can communicate.
> But other than those two things, it should be pretty straightforward.
> What is different about this than what you are trying to do?
>
> Jay

I think you're right, the sandbox code is fine enough to use.  I was
trying to remember why I hadn't been exploring this method, but quickly
rediscovered it:

racket-sandbox.rkt> (define evalu8
                      (make-evaluator 'racket/base))

; current-load-relative-directory: `exists' access denied for 
/home/cwebber/sandbox/
; Context:
;  
/gnu/store/8iy4dl15yl016vgkd040njzf9351hh7j-racket-7.3/share/racket/pkgs/sandbox-lib/racket/sandbox.rkt:716:0
 evaluate-program
;  
/gnu/store/8iy4dl15yl016vgkd040njzf9351hh7j-racket-7.3/share/racket/pkgs/sandbox-lib/racket/sandbox.rkt:853:2
 user-process

Looks like this is because I'm running Racket on Guix; the other source
I can find of this coming up is
  
https://users.racket-lang.narkive.com/A6CLMoNo/question-about-sandbox-rktl-failing-its-unit-test
and it would indeed make sense if it *was* related to symbolic links,
since Guix makes heavy use of symlinks for its functional package
management.

Looks like the problem is security guards really:

racket-sandbox.rkt> (parameterize ([sandbox-security-guard      
(current-security-guard)])
                      (define evalu8
                        (make-evaluator 'racket/base))
                      (evalu8 '(+ 1 2 3)))
6

Anyway that's an unrelated bug, but probably one I should file.
Nonetheless I think even in the interim I have a way to move forward,
thanks!

-- 
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/87k186gz2v.fsf%40dustycloud.org.

Reply via email to