Fix "install: skipping file '/dev/stdin', as it was replaced while being copied" on MacOS#682
Merged
Conversation
…ing copied" on MacOS Fixes: ```sh direnv: loading ~/dev/foo/.envrc direnv: using nix install: skipping file '/dev/stdin', as it was replaced while being copied direnv: nix-direnv: Using cached dev shell ``` Seems to be from commit: nix-community@01fdb24 Instead of using `install`, we use `rm -f` + `cat` + `chmod`, no longer a single command, but it works.. > The rm -f handles the original issue (chmod failing when file is owned by another user) by removing the old file first so cat creates a new one owned by the current user. Essentially , before: ```sh # Use install -m instead of cat + chmod to atomically create the file with # correct permissions. This works even when an existing file is owned by # another user, as install unlinks and recreates the file. install -m 755 /dev/stdin "${layout_dir}/bin/nix-direnv-reload" <<-EOF ``` After: ```sh # Remove first to handle case where file is owned by a different user rm -f "${layout_dir}/bin/nix-direnv-reload" cat >"${layout_dir}/bin/nix-direnv-reload" <<-EOF ``` And after the heredoc closing EOF, `chmod +x "${layout_dir}/bin/nix-direnv-reload"`. --- Could be related to NixOS/nix#9330 ?
Contributor
|
Thank you. Merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Running:
Seems to be from commit: 01fdb24
Instead of using
install, we userm -f+cat+chmod, no longer a single command, but it works..Essentially , before:
After:
And after the heredoc closing EOF,
chmod +x "${layout_dir}/bin/nix-direnv-reload".Could be related to NixOS/nix#9330 ?
This now works as expected for me, but the weird part is that it seems to be fine on Linux, from my testing. I'm going to guess MacOS might still have the file open or something, especially if you use something like Kandji (enterprise MDM file scanning policy thing), but could also be an issue with antivirus if users use something like that (I don't, just another theory)?
Feel free to do whatever with this PR, change it, close it, go a different direction -- this fixed it for me.