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

unexpected result due to paths stripping trailing / #10262

Open
lolbinarycat opened this issue Mar 17, 2024 · 3 comments
Open

unexpected result due to paths stripping trailing / #10262

lolbinarycat opened this issue Mar 17, 2024 · 3 comments
Labels
bug language The Nix expression language; parser, interpreter, primops, evaluation, etc

Comments

@lolbinarycat
Copy link

Describe the bug

the recommended way to convert a string to a path is by concatenating it with another path.

however, if you concatenate multiple strings together, you may not get the result you expect

Steps To Reproduce

  1. $ nix repl
  2. nix-repl> /bin + "/" + "sh"
  3. /binsh

Expected behavior

the repl should print /bin/sh, or at the very least print a warning about the trailing / being ignored.

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

Additional context

the workaround it to parenthesize the rhs: /bin + ("/" + "sh")

i ran into this when trying to implement something similar to the nixpkgs by-name system.

Priorities

Add 👍 to issues you find important.

@thufschmitt
Copy link
Member

That is a quite annoying behaviour, but also something that can't be changed without breaking backwards-compatibility.

Extra motivation for NixOS/rfcs#137 I guess :/

@thufschmitt thufschmitt added the language The Nix expression language; parser, interpreter, primops, evaluation, etc label Mar 20, 2024
@lolbinarycat
Copy link
Author

@thufschmitt surely we can print a warning of some sort when just "/" is appended to a path?

@thufschmitt
Copy link
Member

@thufschmitt surely we can print a warning of some sort when just "/" is appended to a path?

Right, that is something that would make a lot of sense.
It's kinda blocked on #10281 atm, but if you feel like helping there, that would be immensely appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug language The Nix expression language; parser, interpreter, primops, evaluation, etc
Projects
None yet
Development

No branches or pull requests

2 participants