-
Notifications
You must be signed in to change notification settings - Fork 413
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
Tweak mkdir_p uses #2159
Tweak mkdir_p uses #2159
Conversation
src/action_exec.ml
Outdated
else if Path.exists path then | ||
() | ||
else | ||
die "action attempted to create %a outside the build dir" Path.pp path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit unfortunate that we can't give the user a proper location here, but passing the location along would be quite painful
One sec, where does such an action come from? The |
Additionally, the |
Ah yes, then we can just turn this check into an assert I think.
From the |
Seems good. Or a
These are handled in |
|
The error from the bug report indeed comes from let exec p =
if Path.is_managed p then
Memo.exec def p
else
Exn.code_error "Mkdir_p.exec: attempted to create unmanaged dir"
[ "p", Path.to_sexp p
] So the first commit will fix the bug for sure. The second commit was a preventative measure after reviewing more uses of |
The first commit fixes a bug reported in #2158 The second commit can be omitted, but I think it would be useful to turn it into |
It would be nice to have a test for this because I imagine that use case is very easy to forget about and break in the future. |
I'll add a test case. |
Turning it into a code error seems good. However, Dune should never try to create directories outside of the workspace. So I feel like we are hiding a real problem by silently ignoring external mkdirs when the external path exists. |
Sorry, I read the code wrong, I thought this was touching action_exec.ml. However, looking at the stacktrace, you are right that this come from a chdir. What we should do is not call Mkdir_p for external chdirs. For instance, we could replace |
Managed? If we're restricting this, I think we should go all the way and only allow build dirs. Chdir'ing into the source dir seems dangerous to me. Just to confirm: #2158 is not considered to be a regression, and that we indeed don't allow to chdir into external paths. |
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
I removed the "fix" which ignored the |
Seems good to me |
If the directory that we're trying to create exists, then this is never an error.
We now forbid actions to create external or source dirs.
This should fix #2158