[racket] [Racket] Making Racket find files

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Fri Feb 15 10:07:17 EST 2013

When you write something like this:

    #lang racket
    (require "myfile.rkt")

and run that, it looks for "myfile.rkt" in the same directory that the
file you are running is in.

If you're running racket at a command line, like this:

% racket.exe "myfile.rkt"

then racket looks for "myfile.rkt" in the current directory of the command line.

If you're running racket at the command line, and then using the REPL,
like this:

% racket.exe
> (require "myfile.rkt")

then racket again looks for "myfile.rkt" in the directory that the
command line was in when you started racket.

In the latter two cases, you can change this within Racket by setting
the `current-directory` parameter.

Racket doesn't ever look at the system path to try to find files to
use with `require`.

Hopefully that helps,
Sam

On Fri, Feb 15, 2013 at 9:55 AM, John Sampson <jrs.idx at ntlworld.com> wrote:
> On Feb 1 I wrote:
>
> "I have not been able to find a succinct description how to cope with the
> Windows directory system to make Racket find user-created files, either to
> run them as programs or open them as data sources or destinations. Perhaps
> there is a particular directory where they have to be for Racket to find
> them, and this can be set as a default in some way (environment variable or
> whatever)."
>
> So can Racket be made to read environment variables such as "path" in
> Windows 7? Or does one have to write out the whole path
> of a file? If so - forward slashes or backslashes? How many times do they
> have to be escaped?
>
> Regards
>
> John Sampson
>
>
>
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

Posted on the users mailing list.