-
Notifications
You must be signed in to change notification settings - Fork 395
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
fix(pkg): Create temporary directories on same FS #10214
Conversation
Wouldn't it be possible to use the same trick that I did for |
Yes, that's a good solution, I'll rework it. |
5c1f10b
to
e9e9efc
Compare
I've changed it in the places where this was possible but for I dislike duplicating |
Yes, they're not always going to match, but we can just check if
You can create a new module for it in dune_pkg. Note that there's no need to add a hook manually - there's one added automatically. By the way, I think we are creating too many temporary directories for some of these jobs. For example, we should reuse a temp directory for downloading and untaring. |
68cbbdd
to
675bd91
Compare
Is this ready for review now? |
@Leonidas-from-XIV Just making sure we don't forget about this change. This is necessary for package management to work on machines where |
675bd91
to
67cc276
Compare
Yes, sorry, I've been busy with other stuff. I just looked through it and I think it can be reviewed. Just rebased it on
Possibly, but creating temporary directories is cheap (1 inode) and fast and the PR as-is solves the failure I get on every |
let extract ~archive ~target = | ||
let* () = Fiber.return () in | ||
let tar = Lazy.force bin in | ||
let target_in_temp = | ||
let prefix = Path.basename target in | ||
let suffix = Path.basename archive in | ||
match target with |
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.
I think this now assumes that target
always lives in Path.Build.t
? We should do one of the following:
- changing target to be
Path.Build.t
- assert that this is the case
- revert back to the old code for handling non build directories.
#3 would be my preference as we need code like this in other parts of dune.
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.
Good point, there was indeed an issue where it would write to the wrong place. I changed it to check for the build folder and only create it in the build folder in that case. However in the other case we cannot use Temp.create
with rename
as Temp.create
will (on my system) always create in /tmp
and it will always fail unless the target is in /tmp
as well.
So I used the "subdir of parent dir" approach here as well.
67cc276
to
afaf224
Compare
Fixes ocaml#10213 Signed-off-by: Marek Kubica <marek@tarides.com>
afaf224
to
e4d6474
Compare
e4d6474
to
14c5c42
Compare
LGTM. I just made some minor adjustment to reduce repetitive code. |
The problem in #10213 is that
Temp.create
creates a temporary directory and thenPath.rename
is used to move the files to the actual target directory. This unfortunately only works if the directory thatTemp.create
picks and~target
are on the same file system.Multiple solutions exist:
target
is also on the same file system as~target
. This isn't necessarily true, but given we write to_build
it should be true in most cases.This PR attempts #1. An unfortunate consequence of this is that
Path.mkdir_p
is necessary to create the parent directory and if it didn't exist, in the case of failure it is left behind and not deleted. We could probably solve this by keeping track of directories that are created in such case, if it proves to be an issue. Input welcome!Fixes #10213