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

the empty string is only a valid regex when built with libstdc++ and not with libc++ #7208

Open
symphorien opened this issue Oct 23, 2022 · 1 comment
Labels

Comments

@symphorien
Copy link
Member

Describe the bug

builtins.match "" "" evaluates only on linux and on darwin. This seems silly but leads to problems, see NixOS/nixpkgs#177273 (comment)

Steps To Reproduce

  1. run nix repl
  2. type builtins.match "" ""
  3. returns [] on linux and error: invalid regular expression '' on darwin

Expected behavior

Same behavior. An error is probably a better idea but I wonder for backward compatibility. The issue I link suggests such an abuse in nixpkgs would have been noticed, so the worry about backward compat is only for other code bases.

nix-env --version output
nix-env (Nix) 2.8.1

Additional context
NixOS/nixpkgs#197374

@SharzyL
Copy link
Contributor

SharzyL commented May 14, 2024

I also encountered this issue (when struggling with https://github.com/nix-community/home-manager/blob/master/modules/services/gpg-agent.nix#L51).

Consisteny between platforms should be important for Nix. Since libc++ and libstdc++ are not consistent, maybe we can

  1. Treat empty string regex specially to ensure the same result on both platforms.
  2. Or switch to something other than std::regex

SharzyL added a commit to SharzyL/home-manager that referenced this issue May 14, 2024
`splitString "" "some string"` would throw exception `error: invalid
regular expression` on Darwin (or accurately, on Nix built against
libc++). Refer to NixOS/nix#7208 for
details.

Before Nix handles that issue correctly, we should refrain from using
`splitString ""`, and luckliy `lib.stringAsChars` can do the same thing.
SharzyL added a commit to SharzyL/home-manager that referenced this issue May 28, 2024
`splitString "" "some string"` would throw exception `error: invalid
regular expression` on Darwin (or accurately, on Nix built against
libc++). Refer to NixOS/nix#7208 for
details.

Before Nix handles that issue correctly, we should refrain from using
`splitString ""`, and luckliy `lib.stringAsChars` can do the same thing.
rycee pushed a commit to nix-community/home-manager that referenced this issue May 28, 2024
`splitString "" "some string"` would throw exception `error: invalid
regular expression` on Darwin (or accurately, on Nix built against
libc++). Refer to NixOS/nix#7208 for
details.

Before Nix handles that issue correctly, we should refrain from using
`splitString ""`, and luckliy `lib.stringAsChars` can do the same thing.
pasqui23 pushed a commit to pasqui23/home-manager that referenced this issue Jun 3, 2024
`splitString "" "some string"` would throw exception `error: invalid
regular expression` on Darwin (or accurately, on Nix built against
libc++). Refer to NixOS/nix#7208 for
details.

Before Nix handles that issue correctly, we should refrain from using
`splitString ""`, and luckliy `lib.stringAsChars` can do the same thing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants