Skip to content

fix: Renames if source and destination are on different filesystems - #503

Closed
js-murph wants to merge 2 commits into
cashapp:masterfrom
js-murph:master
Closed

fix: Renames if source and destination are on different filesystems#503
js-murph wants to merge 2 commits into
cashapp:masterfrom
js-murph:master

Conversation

@js-murph

@js-murph js-murph commented Aug 20, 2025

Copy link
Copy Markdown

What?

Has a fallback strategy for moving files when it's unable to perform an os.Rename()

Why?

If the source and destination are on different mount locations then the Rename will fail with an error like...

rename /root/.cache/hermit/pkg/hermit@square /root/.cache/hermit/pkg/.hermit@square.old: invalid cross-device link

This has a fallback to copy the file if it fails to perform the rename.

@alecthomas

Copy link
Copy Markdown
Collaborator

How can those two files possibly be on different file systems?

@js-murph

Copy link
Copy Markdown
Author

How can those two files possibly be on different file systems?

I've dropped you a message with a more thorough history of the investigation. But the tldr is that if you place a hermit package in a docker image, run that image as a container and it hits this block of code the package will be on the lowerdir of overlayfs but new data when os.Rename() runs is written to the upperdir resulting in the error in the original comment.

This PR is possibly not for merging, there might be a better way to fix this, I just wanted to share a possible solution.

@alecthomas

Copy link
Copy Markdown
Collaborator

Ah! Somewhat surprisingly, your comment in here makes more sense than the other one! 😂

So the problem is caused by Hermit trying to update itself from within Docker? Maybe we should add a flag to disable updates... or step back and think.

@js-murph

js-murph commented Aug 20, 2025

Copy link
Copy Markdown
Author

Ah! Somewhat surprisingly, your comment in here makes more sense than the other one! 😂

So the problem is caused by Hermit trying to update itself from within Docker? Maybe we should add a flag to disable updates... or step back and think.

I find if I write a sentence enough times it will eventually make sense to someone 😂. Disabling the updates would fix this I think, there are also times where we've relied on that auto-updating feature to roll out fixes. I'm ok either way but it may have implications for releasing hermit changes.

Perhaps @wsutina or @mpeyper should weigh in as this affects them more.

@js-murph js-murph closed this Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants