# Path produced by define-runtime-path does not work on Win(11)

**URL:** <https://racket.discourse.group/t/path-produced-by-define-runtime-path-does-not-work-on-win-11/2442>\
**Category:** Questions & Answers\
**Created:** [October 29, 2023, 2:36pm UTC](https://racket.discourse.group/t/path-produced-by-define-runtime-path-does-not-work-on-win-11/2442 "2023-10-29T14:36:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hrvoje064](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/hrvoje064/32/729_2.png) [@hrvoje064](https://racket.discourse.group/u/hrvoje064)\
**Post date:** [October 29, 2023, 2:36pm UTC](https://racket.discourse.group/t/path-produced-by-define-runtime-path-does-not-work-on-win-11/2442/1 "2023-10-29T14:36:45Z")

</div>

Following the advice from one previous reply to my question, I'm now using (define-runtime-path ...), instead of (current-directory). This has solved one of my problems, namely, the program can now find "scribblings/math-quiz.html" file, wherever it is installed relative to the math-quiz module.  
However, both define-runtime-path, and current-directory have the same problem on Windows (that is W11 - the only one I have here to test).  
The path returned (when this is run as Package install from [racket-lang.org](http://racket-lang.org)), on W11 computer is with backslashes as in c:\dir\dir\...\scribblings\math-quiz.html  
This seemed OK to me at first, but math-quiz would not display the html file, and would report the error that file can not be found. All the time on Linux (where I program anyway), the file was found because the path was reported as: /home/dir/dir.../scribblings/math-quiz.html.

My final code for opening HTML docs is this:

```scheme
(define (fix-path path-str)
  (list->string
   (map (lambda (c) (case c
                      ((#\\) #\/)
                      (else c))) (string->list path-str))))

(define-runtime-path scribble-path "scribblings/math-quiz.html")

(define menu-item-html (new menu-item%
                            [label "HTML Documentation"]
                            [parent help-menu]
                            [callback
                             (lambda (mi e)
                               (send-url
                                (fix-path
                                 (path->string scribble-path))))]))

```

This works both on Linux and on Windows.  
So, why does W11 accept Linux path string, but not the path string that Racket returns as windows path?

---

<div class="post-metadata">

**Author:** ![usao](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/usao/32/1375_2.png) [@usao](https://racket.discourse.group/u/usao)\
**Post date:** [October 30, 2023, 1:18am UTC](https://racket.discourse.group/t/path-produced-by-define-runtime-path-does-not-work-on-win-11/2442/2 "2023-10-30T01:18:34Z")

</div>

I think you should try [`send-url/file`](https://docs.racket-lang.org/net/sendurl.html#%28def._%28%28lib._net%2Fsendurl..rkt%29._send-url%2Ffile%29%29). The reason is that URIs (_not_ filenames!) are encoded with forward slashes on Windows.

---

<div class="post-metadata">

**Author:** ![hrvoje064](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/hrvoje064/32/729_2.png) [@hrvoje064](https://racket.discourse.group/u/hrvoje064)\
**Post date:** [October 30, 2023, 4:36am UTC](https://racket.discourse.group/t/path-produced-by-define-runtime-path-does-not-work-on-win-11/2442/3 "2023-10-30T04:36:46Z")

</div>

Yes, this works. Thanks for the explanation.

My first fix is like this:

```scheme
(define-runtime-path scribble-path "scribblings")
(define scribble-path-string (path->string scribble-path))

(if (eq? (system-type) 'windows)
    (set! scribble-path-string
          (string-append scribble-path-string "\\math-quiz.html"))
    (set! scribble-path-string
          (string-append scribble-path-string "/math-quiz.html")))

(define menu-item-html (new menu-item%
                            [label "HTML Documentation"]
                            [parent help-menu]
                            [callback
                             (lambda (mi e)
                               (send-url/file scribble-path-string))]))

```

But after further testing on W11, I found that even this works (forcing unix / slash at the end of windows path that starts with backslashes).

```scheme
(define-runtime-path scribble-path "scribblings/math-quiz.html")
(define scribble-path-string (path->string scribble-path))

(define menu-item-html (new menu-item%
                            [label "HTML Documentation"]
                            [parent help-menu]
                            [callback
                             (lambda (mi e)
                               (send-url/file scribble-path-string))]))

```

Anyway, I will stay with the first solution, just to be safe.
