Skip to content

unexpected result due to paths stripping trailing / #10262

@lolbinarycat

Description

@lolbinarycat

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglanguageThe Nix expression language; parser, interpreter, primops, evaluation, etc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions