You probably want to use `define-runtime-path`, like this: ``` (require racket/runtime-path) (define-runtime-path rtd "realtime-test-data.rkt") (define (fun-timed-test-2) (define ip (open-input-file rtd)) ... rest of function ...) ```
Sam On Tue, May 12, 2015 at 11:42 AM thomas.lynch < thomas.ly...@reasoningtechnology.com> wrote: > I created a collection, then used raco to install it. > > Ran into a problem where a test function within module X in the collection > accesses a file in the same directory as the source code: > > (define (fun-timed-test-2) > (define ip (open-input-file "realtime-test-data.rkt")) > (match-define (list completed result) (fun-timed 2 (λ(e#) (read-line > ip)))) > (close-input-port ip) > (and completed (string=? result "#|")) > ) > > Now when this is run: > > <pkgs>/liquid-lib/liquid/realtime> (fun-timed-test-2) > ; open-input-file: cannot open input file > ; path: > /home/deep/liquid-lib/examples/keyword-ap/realtime-test-data.rkt > ; system error: No such file or directory; errno=2 > ; [,bt for context] > > The test data file is there in the same directory with the module (in > ../realtime/), but racket is looking for the file in the directory the > function is being invoked from (../examples/keyword-ap/). > > I've gone through the documentation, and the collects path doesn't help, > because this was a directory install, so the catalog is pointing to the > original source directory. There is a function (get-module-path) but I'm > not sure that is doing what I want, or at least I don't know the correct > incantation to make it go at it isn't giving me the path back from > (get-module-path X). > > Will someone please share the incantation for getting the path to the data > file, or otherwise opening it? > > -- > 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. > 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 racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.