Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodePackages binaries fail because of DOS line endings #216306

Closed
blitz opened this issue Feb 14, 2023 · 3 comments · Fixed by #216728
Closed

nodePackages binaries fail because of DOS line endings #216306

blitz opened this issue Feb 14, 2023 · 3 comments · Fixed by #216728

Comments

@blitz
Copy link
Contributor

blitz commented Feb 14, 2023

Describe the bug

When building nodePackages.meshcommander the resulting binary contains ^M in the shebang line. This causes the binary to fail to execute.

$ nix shell nixpkgs#nodePackages.meshcommander
$ meshcommander 
/usr/bin/env: ‘node\r’: No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines

$ hexdump -C $(which meshcommander)
00000000  23 21 20 2f 75 73 72 2f  62 69 6e 2f 65 6e 76 20  |#! /usr/bin/env |
00000010  6e 6f 64 65 0d 0a 72 65  71 75 69 72 65 28 22 2e  |node..require(".|
                      ^^

The bug was introduced between 22.05 and 22.11:

$ nix run nixpkgs#nodePackages.meshcommander
/usr/bin/env: ‘node\r’: No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines

$ nix run nixpkgs/nixos-22.11#nodePackages.meshcommander
/usr/bin/env: ‘node\r’: No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines

$ nix run nixpkgs/nixos-22.05#nodePackages.meshcommander
MeshCommander running on http://127.0.0.1:3000.

Steps To Reproduce

  1. Build pkgs.nodePackages.meshcommander
  2. Execute meshcommander

Expected behavior

The binary runs and doesn't die on a broken shebang.

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

$ nix run nixpkgs#nix-info -- -m
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.10, NixOS, 22.11 (Raccoon), 22.11.20230209.49efda9`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.1`
 - channels(root): `""`
 - channels(julian): `""`
 - nixpkgs: `not found`
@winterqt
Copy link
Member

@lilyinstarlight This looks fun 😰

@lilyinstarlight
Copy link
Member

I wonder if this was a regression from me making node2nix manually handle bin stuff instead of letting npm (not) handle it

I can maybe make a quick patch to node2nix's node-env to dos2unix all bin scripts with shebangs in a line right after this one:

https://github.com/svanderburg/node2nix/blob/315e1b85a6761152f57a41ccea5e2570981ec670/nix/node-env.nix#L537

@lilyinstarlight
Copy link
Member

I've opened #216728 with a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants