# How to set the working directory in DrRacket on Windows?

**URL:** <https://racket.discourse.group/t/how-to-set-the-working-directory-in-drracket-on-windows/4118>\
**Category:** General\
**Created:** [February 20, 2026, 7:52pm UTC](https://racket.discourse.group/t/how-to-set-the-working-directory-in-drracket-on-windows/4118 "2026-02-20T19:52:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MickeyKnox](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@MickeyKnox](https://racket.discourse.group/u/MickeyKnox)\
**Post date:** [February 20, 2026, 7:52pm UTC](https://racket.discourse.group/t/how-to-set-the-working-directory-in-drracket-on-windows/4118/1 "2026-02-20T19:52:48Z")

</div>

I've developed my app on Linux and run it like this:

```
projects/new> racket -t src/main.rkt

```

Now I want to run it on Windows and I'm getting this error:

```
open-input-file: cannot open input file
  path: ...\projects\new\src\assets\world.json
  system error: The system cannot find the path specified.; win_err=3

```

That makes sense, since the assets folder is not in src. This is my folder structure:

```
new/
 * src/
     * main.rkt
     * ...
 * assets/
     * world.json
     * ...

```

How can I tell DrRacket that the current working directory should be `projects/new` and not `projects/new/src`?

I would like to do this not in code, but more like an environment variable setup.

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [February 20, 2026, 8:04pm UTC](https://racket.discourse.group/t/how-to-set-the-working-directory-in-drracket-on-windows/4118/3 "2026-02-20T20:04:13Z")

</div>

You need to use a "runtime path".  
These are resolved relative to the source path,  
not the current path.

> **[15.2.5 Declaring Paths Needed at Run Time🔗ℹ - 15.2 Filesystem](https://docs.racket-lang.org/reference/Filesystem.html#(part._runtime-path))**

---

<div class="post-metadata">

**Author:** ![MickeyKnox](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@MickeyKnox](https://racket.discourse.group/u/MickeyKnox)\
**Post date:** [February 20, 2026, 8:16pm UTC](https://racket.discourse.group/t/how-to-set-the-working-directory-in-drracket-on-windows/4118/4 "2026-02-20T20:16:09Z")

</div>

I don't get it. I've read the documentation for `define-runtime-path`, but in the first example given (`data.txt`) it's also just a relative path. What's the point?

And furthermore, it seems that I would have to do that for every single file I want to open. That seems quite cumbersome...

If I'm making my life unnecessary hard with this folder structure, I wouldn't mind changing it. However, I'd like somehting a bit more sophisticated than just putting everything in a single folder.

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [February 20, 2026, 8:47pm UTC](https://racket.discourse.group/t/how-to-set-the-working-directory-in-drracket-on-windows/4118/5 "2026-02-20T20:47:47Z")

</div>

I suppose you could do this:

```scheme
(define project-root
  (or (getenv "RACKET_PROJECT_ROOT")
      (current-directory))) ; fallback if not set

(current-directory project-root)

```

---

<div class="post-metadata">

**Author:** ![samth](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/samth/32/3_2.png) [@samth](https://racket.discourse.group/u/samth)\
**Post date:** [February 20, 2026, 9:48pm UTC](https://racket.discourse.group/t/how-to-set-the-working-directory-in-drracket-on-windows/4118/6 "2026-02-20T21:48:20Z")

</div>

1. The point is that when you use `define-runtime-path`, nothing depends on the current working directory. You use a relative path there, and it always opens the path relative to that source file.
2. To avoid doing it for every distinct file, use `define-runtime-path` to specify a directory such as `assets` and then use `build-path` together with that path.

---

<div class="post-metadata">

**Author:** ![MickeyKnox](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@MickeyKnox](https://racket.discourse.group/u/MickeyKnox)\
**Post date:** [February 20, 2026, 10:03pm UTC](https://racket.discourse.group/t/how-to-set-the-working-directory-in-drracket-on-windows/4118/7 "2026-02-20T22:03:59Z")

</div>

I must've missed that the path for `define-runtime-path` is relative to the source file and not the working directory. With that information it makes perfect sense. Thank you for pointing that out.

Will this still work once I create an executable? The executable will be in `new/`.

---

<div class="post-metadata">

**Author:** ![samth](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/samth/32/3_2.png) [@samth](https://racket.discourse.group/u/samth)\
**Post date:** [February 20, 2026, 10:24pm UTC](https://racket.discourse.group/t/how-to-set-the-working-directory-in-drracket-on-windows/4118/8 "2026-02-20T22:24:57Z")

</div>

Yes, one of the big advantages is that it works with executables. If you plan to move to a different place, you may also need `raco distribute`.
