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

Poor diagnostics for set -> string type coercion errors. #561

Open
michaelsproul opened this issue Jun 19, 2015 · 12 comments
Open

Poor diagnostics for set -> string type coercion errors. #561

michaelsproul opened this issue Jun 19, 2015 · 12 comments
Assignees
Labels
error-messages Confusing messages and better diagnostics UX The way in which users interact with Nix. Higher level than UI.

Comments

@michaelsproul
Copy link

I found this error quite unhelpful:

$ sudo nixos-rebuild test
building Nix...
building the system configuration...
error: cannot coerce a set to a string, at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/types.nix":103:79
(use ‘--show-trace’ to show detailed location information)

The position given for the error is within the NixOS source, so I figured I'd run it again with --show-trace.

$ sudo nixos-rebuild test --show-trace
building Nix...
building the system configuration...
error: while evaluating the attribute ‘config.system.build.toplevel’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/system/activation/top-level.nix":228:5:
while evaluating ‘fold’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":20:19, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/system/activation/top-level.nix":122:12:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":27:8:
while evaluating ‘showWarnings’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/system/activation/top-level.nix":91:18, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/system/activation/top-level.nix":98:16:
while evaluating ‘fold’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":20:19, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/system/activation/top-level.nix":91:23:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":27:8:
while evaluating the attribute ‘warnings’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/attrsets.nix":135:44:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":26:45, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/attrsets.nix":135:52:
while evaluating the attribute ‘value’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":206:9:
while evaluating the option `warnings':
while evaluating ‘id’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/trivial.nix":9:8, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":204:15:
while evaluating ‘fold’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":20:19, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":187:12:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":27:8:
while evaluating ‘filterOverrides’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":277:21, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":182:20:
while evaluating ‘concatMap’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":54:18, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":284:8:
while evaluating ‘concatMap’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":54:18, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":110:20:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":110:31, called from undefined position:
while evaluating ‘dischargeProperties’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":247:25, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":112:65:
while evaluating the attribute ‘config."${name}"’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/system/boot/systemd.nix":891:5:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/attrsets.nix":160:10, called from undefined position:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/system/boot/systemd.nix":891:51, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/attrsets.nix":160:16:
while evaluating ‘optional’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":105:20, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/system/boot/systemd.nix":892:7:
while evaluating the attribute ‘serviceConfig.Type’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/attrsets.nix":135:44:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":26:45, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/attrsets.nix":135:52:
while evaluating the attribute ‘value’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":206:9:
while evaluating the option `systemd.services.cron.serviceConfig':
while evaluating ‘id’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/trivial.nix":9:8, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":204:15:
while evaluating ‘fold’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":20:19, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":187:12:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":27:8:
while evaluating ‘filterOverrides’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":277:21, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":182:20:
while evaluating ‘concatMap’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":54:18, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":284:8:
while evaluating ‘concatMap’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":54:18, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":110:20:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":110:31, called from undefined position:
while evaluating ‘dischargeProperties’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":247:25, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":112:65:
while evaluating the attribute ‘condition’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":324:14:
while evaluating the attribute ‘condition’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":324:14:
while evaluating the attribute ‘preStart’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/attrsets.nix":135:44:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":26:45, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/attrsets.nix":135:52:
while evaluating the attribute ‘value’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":206:9:
while evaluating the option `systemd.services.cron.preStart':
while evaluating ‘id’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/trivial.nix":9:8, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":204:15:
while evaluating ‘fold’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":20:19, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":187:12:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":27:8:
while evaluating ‘filterOverrides’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":277:21, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":182:20:
while evaluating ‘concatMap’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":54:18, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":284:8:
while evaluating ‘concatMap’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":54:18, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":110:20:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":110:31, called from undefined position:
while evaluating ‘dischargeProperties’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":247:25, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":112:65:
while evaluating the attribute ‘config."${name}"’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/services/scheduling/cron.nix":105:9:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/services/scheduling/cron.nix":28:19, called from undefined position:
while evaluating the attribute ‘text’ of the derivation ‘system-crontab’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/build-support/trivial-builders.nix":10:14:
while evaluating the attribute ‘paths’ of the derivation ‘system-path’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/build-support/trivial-builders.nix":10:14:
while evaluating the attribute ‘environment.systemPackages’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/attrsets.nix":135:44:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":26:45, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/attrsets.nix":135:52:
while evaluating the attribute ‘value’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":206:9:
while evaluating the option `environment.systemPackages':
while evaluating ‘id’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/trivial.nix":9:8, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":204:15:
while evaluating ‘fold’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":20:19, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:11:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":27:8:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":197:22, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘check’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/types.nix":112:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix":198:16:
while evaluating ‘fold’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":20:19, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/types.nix":112:38:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":27:8:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":94:24, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":94:24, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":94:24, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":94:24, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":94:24, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘fold'’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":23:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:34:
while evaluating anonymous function at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":94:24, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":26:14:
while evaluating ‘check’ at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/types.nix":103:15, called from "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix":94:30:
cannot coerce a set to a string, at "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/types.nix":103:79

Eventually I traced the error to my use of ghc (a set) rather than ghc.ghc784 (a package) in environment.systemPackages. The trace fails to mention ghc, its contents or its location in the configuration file (/etc/nixos/configuration:64). Ideally, I would have liked an error like this:

error: expected a value of type 'package' in 'environment.systemPackages' but received 'ghc' of type 'set' at "/etc/nixos/configuration":64:5
@vcunat
Copy link
Member

vcunat commented Sep 8, 2015

These can get very ugly. Right now the evaluator with --show-trace only output

error: value is a string while a set was expected

and no trace at all. It took me hours before I found where the problem was, among the thousands of (texlive) packages.

vcunat added a commit to vcunat/nixpkgs that referenced this issue Sep 8, 2015
The package "version" clashed with bin.version and it took ages to debug
NixOS/nix#561 (comment)
@Mathnerd314
Copy link
Contributor

Using my latest noisy-nix commits (#612) the errors show as follows:

$ ~/nix/inst/bin/nix-instantiate . --eval --show-trace --strict -A pkgs.texlive.scheme-full
error: while evaluating the attribute ‘pkgs’ at ~/nixpkgs-test/pkgs/tools/typesetting/tex/texlive-new/default.nix:104:7-104:11:
while evaluating list position ‘10928’:
while evaluating a black hole:
value is a string at ~/nixpkgs-test/pkgs/tools/typesetting/tex/texlive-new/bin.nix:17:15-17:19 while a set was expected at ~/nixpkgs-test/pkgs/tools/typesetting/tex/texlive-new/default.nix:113:15-113:65

$ ~/nix/inst/bin/nix-instantiate --show-trace -E 'with import ./nixos/default.nix { configuration = (a @ {pkgs, ...}: (import /etc/nixos/configuration.nix a) // { environment.systemPackages = [ pkgs.haskellPackages ]; }); }; system'
...
while evaluating the attribute ‘pkgs’ of the derivation ‘system-path’ at ~/nixpkgs-test/pkgs/build-support/buildenv/default.nix:38:5-38:9:
while evaluating a black hole at ~/nixpkgs-test/pkgs/build-support/buildenv/default.nix:38:5-38:9:
while calling primop toJSON at ~/nixpkgs-test/pkgs/build-support/buildenv/default.nix:38:12-41:14:
while evaluating list position ‘250’ at ~/nixpkgs-test/pkgs/build-support/buildenv/default.nix:38:12-41:14:
while evaluating the attribute ‘paths’ at ~/nixpkgs-test/pkgs/build-support/buildenv/default.nix:39:7-39:12:
while evaluating list position ‘0’ at ~/nixpkgs-test/pkgs/build-support/buildenv/default.nix:39:7-39:12:
while calling anonymous function at ~/nixpkgs-test/lib/types.nix:117:14-117:24 from ~/nixpkgs-test/pkgs/build-support/buildenv/default.nix:39:7-39:12:
while evaluating the attribute ‘value’ at ~/nixpkgs-test/lib/types.nix:117:17-117:24:
while evaluating a black hole at ~/nixpkgs-test/lib/types.nix:117:17-117:24:
while calling primop foldl' at ~/nixpkgs-test/lib/modules.nix:314:19-317:43:
while calling anonymous function at ~/nixpkgs-test/lib/modules.nix:314:32-316:96 from ~/nixpkgs-test/lib/modules.nix:314:19-317:43:
while calling ‘check’ at ~/nixpkgs-test/lib/types.nix:97:15-97:49 from ~/nixpkgs-test/lib/modules.nix:315:10-315:30:
while calling ‘isStorePath’ at ~/nixpkgs-test/lib/strings.nix:224:17-224:112 from ~/nixpkgs-test/lib/types.nix:97:36-97:49:
while calling primop substring at ~/nixpkgs-test/lib/strings.nix:224:20-224:55:
while evaluating a black hole at ~/nixpkgs-test/lib/strings.nix:224:20-224:55:
while calling primop toString at ~/nixpkgs-test/lib/strings.nix:224:44-224:54:
cannot coerce a set at (string):1:132-1:152 to a string at ~/nixpkgs-test/lib/strings.nix:224:44-224:54

Maybe someone will want to review them...

@michaelsproul
Copy link
Author

@Mathnerd314: That looks quite a bit better.

@domenkozar
Copy link
Member

Similar: #963

@domenkozar domenkozar added improvement UX The way in which users interact with Nix. Higher level than UI. and removed documentation labels Oct 19, 2016
@freddie-freeloader
Copy link

I get this error, for my configuration.nix. I have about 250 values in there. 😭

It's obviously time to tidy up, but until then:

Are there any debugging tactics to track the problematic value down? 🙏

@bjornfor
Copy link
Contributor

bjornfor commented Nov 3, 2016

I have use binary search. Comment out half of the file, test, repeat.

@freddie-freeloader
Copy link

Reminds me of:

Nix won't be complete until it has static typing.

😉

@shlevy shlevy added the backlog label Apr 1, 2018
@domenkozar domenkozar added error-messages Confusing messages and better diagnostics and removed backlog labels Apr 30, 2020
@stale
Copy link

stale bot commented Jun 2, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Jun 2, 2021
@scintill
Copy link

scintill commented Jun 3, 2021

bump to unstalify

@stale stale bot removed the stale label Jun 3, 2021
@milahu
Copy link
Contributor

milahu commented Sep 13, 2021

Are there any debugging tactics to track the problematic value down?

do a manual stack trace, by inserting dozens of

{
  # TRACE
  #someAttr = "some value";
  someAttr =
    lib.traceSeqN 2 { loc = "line 1234"; someAttr = "some value"; }
    "some value"
  ;
}

... to get a feel for the program flow

make --show-trace more verbose

Is your feature request related to a problem? Please describe.
I'm always frustrated when ...
... i have an error in my code, but --show-trace is too short for debugging

Describe the solution you'd like
--show-trace should be more verbose,
it should list all function calls, similar to the stack traces in java or javascript

Describe alternatives you've considered
use lib.traceSeq and friends, to manually locate the error in my code

Additional context
#4000

greedy added a commit to greedy/nix that referenced this issue Sep 23, 2021
Previously, type or coercion errors for string interpolation, path
interpolation, and plus expressions were always reported at the
beginning of the outer expression. This leads to confusing evaluation
error messages making it hard to accurately diagnose and then fix the
error.

For example, errors were reported as follows.

```
cannot coerce an integer to a string
1| let foo = 7; in "bar" + foo
 |                 ^

cannot add a string to an integer
1| let foo = "bar"; in 4 + foo
 |                     ^

cannot coerce an integer to a string
1| let foo = 7; in "x${foo}"
 |                  ^
```

This commit changes the ExprConcatStrings expression vector to store a
sequence of expressions *and* their expansion locations so that error
locations can be reported accurately. For interpolation, the error is
reported at the beginning of the entire `${foo}`, not at the beginning
of `foo` because I thought this was slightly clearer. The previous
errors are now reported as:

```
cannot coerce an integer to a string
1| let foo = 7; in "bar" + foo
 |                         ^

cannot add a string to an integer
1| let foo = "bar"; in 4 + foo
 |                         ^

cannot coerce an integer to a string
1| let foo = 7; in "x${foo}"
 |                   ^
```

The error is reported at this kind of precise location even for
multi-line indented strings.

This probably helps with at least some of the cases mentioned in NixOS#561
@stale
Copy link

stale bot commented Apr 16, 2022

I marked this as stale due to inactivity. → More info

@zhaofengli
Copy link
Member

The trace is even worse if you accidentally attempt to access an attset with attrset as a key (e.g., hashes.${stdenv.hostPlatform}):

let
  attr = { foo = "bar"; };
  key = {};
in attr.${key}
$ nix-instantiate --version
nix-instantiate (Nix) 2.13.3

$ nix-instantiate --eval bad-trace.nix --show-trace
error: value is a set while a string was expected

       at «none»:0: (source not available)

Same with 2.3:

$ nix-instantiate --version
nix-instantiate (Nix) 2.3.16

$ nix-instantiate --eval bad-trace.nix --show-trace
error: value is a set while a string was expected

@stale stale bot removed the stale label Apr 21, 2023
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

No branches or pull requests