web-server icon indicating copy to clipboard operation
web-server copied to clipboard

web-server/insta sets wrong current-directory

Open samth opened this issue 3 years ago • 4 comments

The value of (current-directory) upon entry to start is the htdocs directory inside the web-server collection, not the directory that Racket started in (as for other Racket programs) or the directory containing the program.

samth avatar Dec 22 '20 14:12 samth

This is documented in the servlet-current-directory keyword of serve/servlet

And the insta documentation ends with

“ If you want more control over specific parameters, keep reading about web-server/servlet-env https://docs.racket-lang.org/web-server/run.html?q=Servlet#%28mod-path._web-server%2Fservlet-env%29 .”

On Tue, Dec 22, 2020 at 9:46 AM Sam Tobin-Hochstadt < [email protected]> wrote:

The value of (current-directory) upon entry to start is the htdocs directory inside the web-server collection, not the directory that Racket started in (as for other Racket programs) or the directory containing the program.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/racket/web-server/issues/99, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABYZ6XWCQRUMKOZLCNJWXDSWCWKZANCNFSM4VFXHGKA .

--

-- Jay McCarthy Associate Professor @ CS @ UMass Lowell http://jeapostrophe.github.io Vincit qui se vincit.

jeapostrophe avatar Dec 22 '20 15:12 jeapostrophe

Unfortunately this works out poorly for the Continue tutorial, which uses (current-directory) and web-server/insta.

I see a few options:

  • Change the tutorial to use serve/servlet and #:servlet-current-directory
  • Change web-server/insta to set the current directory.
  • Change the tutorial to use define-runtime-path, as in my suggestion on the mailing list.

samth avatar Dec 22 '20 15:12 samth

I feel like it is plausible that web-server/insta could change... it feels like it is unlikely to be on the critical path of anyone's work to assume this about the cwd. I think it would be fine to change the tutorial to use d-r-p, although maybe too complicated. I don't think the tutorial should use serve/servlet, unless it is part of a bigger transition in the tutorial to that library.

jeapostrophe avatar Dec 23 '20 02:12 jeapostrophe

Change it to (current-directory-for-user), then the directory will be the current one

ChengxiX avatar Feb 12 '22 14:02 ChengxiX