Skip to content

buildEnv: don't create directory if it already exists - #16821

Closed
rasendubi wants to merge 1 commit into
NixOS:masterfrom
rasendubi:buildenv-directory-exists
Closed

rasendubi wants to merge 1 commit into
NixOS:masterfrom
rasendubi:buildenv-directory-exists

Conversation

@rasendubi

Copy link
Copy Markdown
Member
Things done
  • Tested using sandboxing
    (nix.useChroot on NixOS,
    or option build-use-chroot in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • OS X
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

This patch fixes #16614.

The issue was caused by the fact that both /share and
/share/fish/vendor_completions.d end in the pathsToLink. The
pkgs/build-support/buildenv/builder.pl creates /share, then links
/share/fish under /share and then tries to create the directory
/share/fish/vendor_completions.d and fails because it already exists.

The simplest way to reproduce the issue is to build the next Nix
expression:

let pkgs = import <nixpkgs> { };
in pkgs.buildEnv {
  name = "buildenv-issue";

  paths = [
    pkgs.fish
    pkgs.vim
  ];

  pathsToLink = [
    "/share"
    "/share/fish/vendor_completions.d"
  ];
}

This patch makes buildEnv check if directory already exists before
trying to create it.

This patch fixes NixOS#16614.

The issue was caused by the fact that both `/share` and
`/share/fish/vendor_completions.d` end in the `pathsToLink`. The
`pkgs/build-support/buildenv/builder.pl` creates `/share`, then links
`/share/fish` under `/share` and then tries to create the directory
`/share/fish/vendor_completions.d` and fails because it already exists.

The simplest way to reproduce the issue is to build the next Nix
expression:

```nix
let pkgs = import <nixpkgs> { };
in pkgs.buildEnv {
  name = "buildenv-issue";

  paths = [
    pkgs.fish
    pkgs.vim
  ];

  pathsToLink = [
    "/share"
    "/share/fish/vendor_completions.d"
  ];
}
```

This patch makes buildEnv check if directory already exists before
trying to create it.
@mention-bot

Copy link
Copy Markdown

@rasendubi, thanks for your PR! By analyzing the annotation information on this pull request, we identified @edolstra, @aszlig and @abbradar to be potential reviewers

@rasendubi

Copy link
Copy Markdown
Member Author

Well, 2030 packages seem like a mass rebuild.

@rasendubi

Copy link
Copy Markdown
Member Author

Reopened against staging: #16823

@rasendubi rasendubi closed this Jul 9, 2016
@rasendubi
rasendubi deleted the buildenv-directory-exists branch July 14, 2016 23:22
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.

fish: NixOS module is broken because of /share/fish/vendor_completions.d

2 participants