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

request to clarify "illegal name" error #2973

Closed
deliciouslytyped opened this issue Jun 27, 2019 · 1 comment · Fixed by #2974
Closed

request to clarify "illegal name" error #2973

deliciouslytyped opened this issue Jun 27, 2019 · 1 comment · Fixed by #2974
Assignees
Labels
error-messages Confusing messages and better diagnostics UX The way in which users interact with Nix. Higher level than UI.

Comments

@deliciouslytyped
Copy link

deliciouslytyped commented Jun 27, 2019

Scenario:
While playing in the REPL with the following snippet:

mapDir = f: path:
  let
    files = builtins.readDir path;
  in
    builtins.mapAttrs (n: v: f (path + ("/" + n)) v) files;

I was confused by the following:

l> mapDir (n: v: "${n}") ./.
illegal name: '.git'

I didn't understand why it was complaining about illegal names, and besides, I wasn't renaming any of the attributes!

So the specific problem here was that interpolating a path doesn't just interpolate the string, it imports the file into the store, and interpolates the store path. This all makes sense after having it explained to me, but it would have been nice if the error message clarified that this wasn't an evaluation error or somesuch.

I don't have any specific fixes in mind, but @grahamc has suggested something like the following as a starting point:

Trying to import «path» in to the Nix store with the name «.foo» is invalid: it must begin with a letter or a number
Note: builtins.path can be used to give it an alternative name, if you cannot rename the file no disk.

In my case this would have told me that I need to figure out why its trying to import a path, and I would have eventually figured out the interpolation behavior.

@grahamc grahamc added error-messages Confusing messages and better diagnostics UX The way in which users interact with Nix. Higher level than UI. labels Jun 27, 2019
@grahamc
Copy link
Member

grahamc commented Jun 27, 2019

void checkStoreName(const string & name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error-messages Confusing messages and better diagnostics UX The way in which users interact with Nix. Higher level than UI.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants