I think we need more of your program to help. In particular, I don't
know what you have in mind with `(define-namespace-anchor a)`, and I
wonder whether your program uses `load` or `dynamic-require`.


I tried completing your example with

app.rkt:

 #lang racket
 (require "words.rkt"
          racket/serialize)

 ;; write serialized
 (writeln (serialize (word 1 2)))
 ;; read something that must have been previously serialized
 (deserialize (read (current-input-port)))

                                         
words.rkt:

 #lang racket
 (require racket/serialize)
 (provide (struct-out word))

 (serializable-struct word
   (type
    ecc.))

but that works as expected, where the serialized output has something
like "#%embedded:g2140:words" instead of a path.


At Fri, 12 Aug 2016 05:53:35 -0700 (PDT), rumpz wrote:
> app.rkt:
> 
> #lang racket
> (require "words.rkt"
>        web-server/servlet)
> 
> ....
> 
> 
> words.rkt:
> 
> #lang racket
> (require racket/serialize)
> (provide (struct-out word) save-words load-words decline)
> 
> (serializable-struct word
>   (type
>    ecc.))
> 
> (define-namespace-anchor a)
> (define ns (namespace-anchor->namespace a))
> 
> ....
> 
> 
> If I compile app.rkt with "raco exe app.rkt" and "raco distribute appdir app"
> and I move the "appdir" directory to another system, when I run ./app it 
> crashes with this error:
> 
> default-load-handler: cannot open module file
>   module path: #<path:/home/rumpz/webapp/words.rkt>
>   path: /home/rumpz/webapp/words.rkt
>   system error: No such file or directory; errno=2
>   context...:
>    standard-module-name-resolver
>    /usr/share/racket/collects/racket/private/serialize.rkt:654:8: loop
>    /usr/share/racket/collects/racket/private/serialize.rkt:649:2: deserialize
>    #%mzc:app: [running body]
> 
> 
> Even if I don't move from my system but just rename words.rkt, it still 
> crashes. From the examples and the documentation I assumed that raco 
> automatically included required modules, but it looks like it's just looking 
> for the .rkt file (and even with the exact path that it has on the original 
> system). What am I doing wrong?
> 
> Also, a secondary problem with modules that may be related: I've tried to 
> make 
> a copy of the "webapp" directory, called webapp2. When I launch app from the 
> new directory, it loads a list of "word" structures from a file I saved them 
> in previously, and try to access them with a "word" field (like "word-type") 
> it crashes with:
> 
> word-type: contract violation;
>  given value instantiates a different structure type with the same name
>   expected: word?
>   given: #<word>
> 
> It's like it marked down somewhere that those structs refer to the definition 
> of "word" in webapp/words.rkt, and not the one in webapp2/words.rkt
> 
> -- 
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to