[racket] Problems using Sandbox and Scribble
I should have guessed that you'd get that error. It's a bug in v6.1.1
that has been fixed in the development version.
Is using a development snapshot an option in your case?
http://www.cs.utah.edu/plt/snapshots/
Otherwise, a possible workaround is to add each module with that error
to `sandbox-namespace-spec`:
(parameterize ([sandbox-namespace-specs
(append (sandbox-namespace-specs)
'(scribble/manual scribble/racket
racket/stxparam-exptime))])
....)
At Wed, 28 Jan 2015 10:56:38 -0700, Lucas Paul wrote:
> Thanks for that, Matthew. Unfortunately, when I try that, I get a new error:
>
> namespace-attach-module: a different instance of the same module is
> already in the destination namespace
> module name: "/usr/share/racket/collects/racket/stxparam-exptime.rkt"
>
> On Tue, Jan 27, 2015 at 2:03 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> > The `#:requires` option of `make-evaluator` requires the named modules
> > in the sandbox's namespace, but the module instances are distinct from
> > any instances in the original namespace.
> >
> > To attach the original namespace's instances to the sandbox's
> > namespace, use the `sandbox-namespace-specs` parameter:
> >
> > (define safe-eval
> > (parameterize ([sandbox-namespace-specs
> > (append (sandbox-namespace-specs)
> > '(scribble/manual scribble/racket))])
> > (make-evaluator 'racket/base
> > #:requires '(scribble/manual scribble/racket))))
> >
> > At Tue, 27 Jan 2015 13:22:01 -0700, Lucas Paul wrote:
> >> Hi.
> >>
> >> I want to evaluate some scribble things (in a sandbox) and then
> >> combine them with other scribble things I already have lying around.
> >> But I'm running into a problem.
> >>
> >> If I, for example, make a nicely formatted (racket) code block in a
> >> sandbox, and then put it in a (para) outside of that sandbox, the
> >> world explodes. Here is a minimal example:
> >>
> >> #lang racket
> >>
> >> (require racket/sandbox
> >> scribble/manual)
> >>
> >> (define safe-eval
> >> (make-evaluator 'racket/base #:requires '(scribble/manual
> scribble/racket)))
> >>
> >> (pretty-print (racket foo)) ; Gives one output
> >> (pretty-print (safe-eval '(racket foo))) ; Gives a slightly DIFFERENT
> output
> >>
> >> (para (racket foo)) ; Finishes happily
> >> (para (safe-eval '(racket foo))) ; Error
> >>
> >> ; end
> >>
> >> This is the error I get:
> >>
> >> para: contract violation
> >> expected: pre-content?
> >> given: (cached-element (style "RktSym" (list 'tt-chars (css-addition
> >> '(collects #"scribble" #"racket.css")) (tex-addition '(collects
> >> #"scribble" #"racket.tex")))) "foo" (vector (style "RktSym" (list
> >> 'tt-chars (css-addition '(collects #"scribble" #"racket...
> >> in: an element of
> >> the rest argument of
> >> (->*
> >> ()
> >> (#:style (or/c style? string? symbol? #f))
> >> #:rest
> >> (listof pre-content?)
> >> paragraph?)
> >> contract from:
> >> <pkgs>/scribble-lib/scribble/base.rkt
> >> blaming: anonymous-module
> >> (assuming the contract is correct)
> >> at: <pkgs>/scribble-lib/scribble/base.rkt:337.2
> >>
> >> What is going on? Why does the same piece of code have two different
> >> results depending on where it's executing? And most importantly, is
> >> there a way for me to get this to work the way I /want/?
> >>
> >> - Lucas Paul
> >> ____________________
> >> Racket Users list:
> >> http://lists.racket-lang.org/users