Skip to content

writers.writePython3: created script fails to run on MacOS #93609

@adrian-gierakowski

Description

@adrian-gierakowski

Describe the bug
Executables produced by writers.writePython3 (and probably also writePython2 etc) fail to run on MacOS

To Reproduce
Steps to reproduce the behavior:

  1. clone https://github.com/adrian-gierakowski/nix-writePython3-broken-on-darwin
  2. run $(nix-build) from top level the repo (assuming POSIX shell)
  3. see it fail

Expected behavior
The command from step 2 should print success

Additional context

This seems to be caused by the fact that ${python3.withPackages}/bin/python which is used for shebang line
in the produced script is itself a "script text executable" which does not seem to work on MacOS.

The repo mentioned above contains a tentative fix, which prepend ${pkgs.bash}/bin/bash to the shebang line in the produced script.

NOTE: the repo above uses my own fork of nixpkgs since dash is currently broken on darwin (and writePython3 depends on dash)

Notify maintainers
@Lassulus

Metadata

  • system: "x86_64-darwin"
  • host os: Darwin 18.7.0, macOS 10.14.6
  • multi-user?: no
  • sandbox: yes
  • version: nix-env (Nix) 2.3.6pre7027_6f162d8
  • channels(adriangierakowski): ""
  • nixpkgs: /nix/store/ciqd3l5bznq5ms389b4w7yjv7vk9vpm0-source

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
- writers.writePython2
- writers.writePython3
- writers.writePython2Bin
- writers.writePython3Bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: darwinRunning or building packages on Darwin6.topic: pythonPython is a high-level, general-purpose programming language.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions