web-server
web-server copied to clipboard
web-server/insta sets wrong current-directory
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.
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.
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.
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.
Change it to (current-directory-for-user)
, then the directory will be the current one