-
-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move Mill process working directory to sandbox #3367
Conversation
I understand the motivation, yet I find it a bit uncommon for a CLI tool to not have the current working directory the same as the directory, from where I started the process. I have to make myself comfortable with this change, I guess. So, is this only changing the pwd of the Mill server process? What's the pwd of the client? And what's the pwd, when Mill runs in |
The client For It's definitely a bit unusual, but even today people shouldn't really be reading or writing stuff out of |
We might need to add something unique to that path, e.g. the process ID, since it's possible to start many |
`os.pwd` is no longer the repo root as of #3367, so we need to explicitly ask for `mill.api.WorkspaceRoot.workspaceRoot` This allows a `installLocalCache`d version of Mill to successfully be used to load a project into IntelliJ via BSP, whereas in `main` that fails due to the incorrect workspace directory
This makes
os.pwd
an empty directory:out/mill-worker-*/sandbox/
for Mill's server mode,out/mill-no-server/sandbox/
otherwiseIn general, code outside of tasks should use
millSourcePath
, while code inside of tasks should useT.dest
or thePathRef
s given to it by upstream tasks. Accessing project files viaos.pwd
can result in tasks not invalidating when files changed.Like #3347, this does not prevent people intentionally walking the filesystem to work mischieve, but it does help mitigate "accidental" usage of
os.pwd
to access project files. The originalos.pwd
is still made available asmill.api.WorkspaceRoot.workspaceRoot
outside of tasks, orT.workspace
inside of tasks, for the occasional scenarios that need it. But at least this adds some partial guardrails against accidentally usingos.pwd
in a way that subverts Mill's expectations, and the APIs that expose the workspace root can be appropriately documented to warn people against doing the wrong thing