NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
13k stars 1.54k forks source link

nix-shell segfaults when reading an empty file #8777

Open plha-demant opened 1 year ago

plha-demant commented 1 year ago

Describe the bug

nix-shell segfaults when given an empty file as single argument.

Steps To Reproduce

  1. Create an empty file. E.g. default.nix rm -f default.nix && touch default.nix
  2. Run:

    nix-shell default.nix
    Segmentation fault

    Expected behavior I was expecting an error message like when you run nix-shell without any arguments:

    nix-shell 
    error: syntax error, unexpected end of file
    
       at /home/johndoe/default.nix:1:1:
    
            1|
             | ^

nix-env --version output Observed in the following versions:


nix (Nix) 2.13.3
nix (Nix) 2.15.1
nix (Nix) 2.16.0
nix (Nix) 2.17.0

**Additional context**

**Priorities**
txtor commented 1 year ago

it works for me on nix 2.16.1 [francesc@ew15 ~]$ rm -f default.nix && touch default.nix [francesc@ew15 ~]$ nix-shell default.nix error: syntax error, unexpected end of file

   at /home/francesc/default.nix:1:1:

        1|
         | ^

1 [francesc@ew15 ~]$ nix --version nix (Nix) 2.16.1

mikyll commented 2 months ago

Getting the same issue.