Skip to content

Darwin: pytest executed from nix develop fails due to /tmp being a symlink #560

@booxter

Description

@booxter
$ nix develop

$ pytest
[...]
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: 	git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: 	git branch -m <name>
To /tmp/nix-shell.jYPQBd/tmpb4jndzb7/nixpkgs/remote
 * [new branch]      HEAD -> master
Switched to a new branch 'pull/363128/merge'
To /tmp/nix-shell.jYPQBd/tmpb4jndzb7/nixpkgs/remote
 * [new branch]      pull/363128/merge -> pull/363128/merge
warning: unknown setting 'sandbox-build-dir'
error: the path '"/tmp"' is a symlink; this is not allowed for the Nix store and its parent directories
========================================================================= short test summary info ==========================================================================
FAILED tests/test_rev.py::test_rev_command - subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command', 'eval', '--impure', '--raw',...
FAILED tests/test_rev.py::test_rev_command_without_nom - subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command', 'eval', '--impur...
FAILED tests/test_rev.py::test_rev_only_packages_does_not_trigger_an_eval - subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command...
FAILED tests/test_pr.py::test_pr_ofborg_eval - subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command', 'eval', '--impure', '--raw...
FAILED tests/test_pr.py::test_pr_local_eval - subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command', 'eval', '--impure', '--raw'...
FAILED tests/test_pr.py::test_pr_local_eval_missing_nom - subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command', 'eval', '--impu...
FAILED tests/test_pr.py::test_pr_github_action_eval - subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command', 'eval', '--impure',...
FAILED tests/test_pr.py::test_pr_local_eval_without_nom - subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command', 'eval', '--impu...
FAILED tests/test_wip.py::test_wip_command - subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command', 'eval', '--impure', '--raw',...
FAILED tests/test_wip.py::test_wip_only_packages_does_not_trigger_an_eval - subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command...
FAILED tests/test_wip.py::test_wip_command_without_nom - subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command', 'eval', '--impur...
FAILED tests/test_pr.py::test_pr_only_packages_does_not_trigger_an_eval - subprocess.CalledProcessError: Command '['nix', '--extra-experimental-features', 'nix-command',...
=========================================================== 12 failed, 5 passed, 1 skipped in 116.45s (0:01:56) ============================================================

And indeed, on Darwin it's a symlink:

(ins)bash-5.2$ ls -ld /tmp
lrwxr-xr-x 1 root wheel 11 Aug 16 14:44 /tmp -> private/tmp

With the following patch, it still fails in a similar fashion:

diff --git a/tests/conftest.py b/tests/conftest.py
index e0f8164..2e79089 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -222,6 +222,7 @@ class Helpers:
 
             # Disable substituters and sandboxing for tests
             os.environ["NIX_CONFIG"] = f"""
+allow-symlinked-store = true
 substituters =
 connect-timeout = 0
 sandbox = false
$ pytest
[...]
* [new ref]         a1d68fa803874a775c51a113750d25260ef3115b -> refs/nixpkgs-review/1
Preparing worktree (detached HEAD a1d68fa)
warning: unknown setting 'sandbox-build-dir'
error:
       … while calling the 'listToAttrs' builtin
         at /Users/ihrachyshka/src/nixpkgs-review/nixpkgs_review/nix/evalAttrs.nix:52:1:
           51|
           52| listToAttrs (concatMap getProperties attrs)
             | ^
           53|

       … while calling the 'concatMap' builtin
         at /Users/ihrachyshka/src/nixpkgs-review/nixpkgs_review/nix/evalAttrs.nix:52:14:
           51|
           52| listToAttrs (concatMap getProperties attrs)
             |              ^
           53|

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: path '//tmp' is a symlink
https://github.com/NixOS/nixpkgs/pull/363128 failed to build: nix --extra-experimental-features nix-command no-url-literals --system aarch64-darwin eval --nix-path nixpkgs=/tmp/nix-shell.jYPQBd/tmpj7bvs70i/cache/nixpkgs-review/pr-363128/nixpkgs nixpkgs-overlays=/tmp/nix-shell.jYPQBd/tmpl71lgrpa --json --impure --no-allow-import-from-derivation --expr (import /Users/ihrachyshka/src/nixpkgs-review/nixpkgs_review/nix/evalAttrs.nix { attr-json = /tmp/nix-shell.jYPQBd/tmpgpai3bki; }) failed to run, /tmp/nix-shell.jYPQBd/tmpgpai3bki was stored inspection

(I've noticed warning: unknown setting 'sandbox-build-dir' message also shown in the output, but not sure if it's relevant.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions