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.
./result/bin/py-test: line 2: syntax error near unexpected token `0'
./result/bin/py-test: line 2: `print(0)'
zsh: exec format error: ./result/bin/py-test
Expected behavior
Output:
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-test with pkgs.python3.withPackages ...:
#!/nix/store/jhbikg6nir868g3wfypi7vppn5mbjhp5-python3-3.7.4-env/bin/python
print(0)
./result/bin/py-test with pkgs.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:
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`
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:
Expected behavior
Output:
Additional context
Everything works as expected if we replace
pkgs.python3.withPackages ...withpkgs.python3. The only difference in the result is the shebang../result/bin/py-testwithpkgs.python3.withPackages ...:./result/bin/py-testwithpkgs.python3:Executing the python executable in the shebang works, as does executing
py-testwith the same executable, that isgives the expected output.
Existing Darwin shebang-related issues:
buildPerlModulebroken on Darwin due to shebang character limit #35353ackinstalls, but reports "use: command not found" #47302However, 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 -mand paste the result.