-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Closed as duplicate of#123067
Closed as duplicate of#123067
Copy link
Labels
0.kind: bugSomething is brokenSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.mdhttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: darwinRunning or building packages on DarwinRunning or building packages on Darwin6.topic: pythonPython is a high-level, general-purpose programming language.Python is a high-level, general-purpose programming language.
Description
Describe the bug
If I package a Python script with python3.withPackages ... as build input then the script will build but not run on Darwin.
To Reproduce
Steps to reproduce the behavior:
- Use MacOS.
- Create default.nix:
let
pkgs = import <nixpkgs> { };
python = pkgs.python3.withPackages (_: []);
in
pkgs.stdenv.mkDerivation rec {
name = "py-test";
buildInputs = [ python ];
unpackPhase = "true";
installPhase = ''
mkdir -p $out/bin
touch $out/bin/py-test
chmod +x $out/bin/py-test
echo "#!${python}/bin/python" >> $out/bin/py-test
echo "print(0)" >> $out/bin/py-test
'';
}
- Build and run:
nix-build
./result/bin/py-test
- Observe unexpected behaviour.
- In bash:
./result/bin/py-test: line 2: syntax error near unexpected token `0'
./result/bin/py-test: line 2: `print(0)'
- In zsh:
zsh: exec format error: ./result/bin/py-test
Expected behavior
Output:
0
Additional context
Everything works as expected if we replace pkgs.python3.withPackages ... with pkgs.python3. The only difference in the result is the shebang.
./result/bin/py-testwithpkgs.python3.withPackages ...:
#!/nix/store/jhbikg6nir868g3wfypi7vppn5mbjhp5-python3-3.7.4-env/bin/python
print(0)
./result/bin/py-testwithpkgs.python3:
#!/nix/store/8r52cdbn9g3sl9pz8vm4xcf7rhrqjqin-python3-3.7.4/bin/python
print(0)
Executing the python executable in the shebang works, as does executing py-test with the same executable, that is
/nix/store/jhbikg6nir868g3wfypi7vppn5mbjhp5-python3-3.7.4-env/bin/python result/bin/py-test
gives the expected output.
Existing Darwin shebang-related issues:
buildPerlModulebroken on Darwin due to shebang character limit #35353ackinstalls, but reports "use: command not found" #47302
However, it does not seem like a problem with the character limit in this case?
Metadata
Please run nix run nixpkgs.nix-info -c nix-info -m and paste the result.
- system: `"x86_64-darwin"`
- host os: `Darwin 16.7.0, macOS 10.12.6`
- multi-user?: `no`
- sandbox: `no`
- version: `nix-env (Nix) 2.2.2`
- channels(anders): `""`
- nixpkgs: `/Users/anders/nixpkgs`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
0.kind: bugSomething is brokenSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.mdhttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: darwinRunning or building packages on DarwinRunning or building packages on Darwin6.topic: pythonPython is a high-level, general-purpose programming language.Python is a high-level, general-purpose programming language.