Skip to content

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

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

rasendubi wants to merge 1 commit into
NixOS:stagingfrom
rasendubi:staging-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

@Profpatsch

Copy link
Copy Markdown
Member

Beautiful, thanks. With your patch applied the example builds, 👍

@rasendubi

Copy link
Copy Markdown
Member Author

Please, wait before merging this. Seems that I found a better patch that fixes both this issue and #16741.

@rasendubi

Copy link
Copy Markdown
Member Author

Superseded by #16828.

@rasendubi rasendubi closed this Jul 9, 2016
@rasendubi
rasendubi deleted the staging-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.

3 participants