commercialhaskell / commercialhaskell/stack
Nix suggestions (e.g. `--show-trace`) misleading
- Dominant language
- Haskell
- Stars
- 4.1k
- Forks
- 850
- Avg merge
- 10h 37m
- Merged PRs (30d)
- 4
Description
If `stack --nix build` gets an error from Nix, it gives out suggestions which don't work for the `stack` command.
### Steps to reproduce
1. Find a Stack project which Nix will struggle with. For example, https://github.com/tip-org/tools sets `resolver` to `lts-7.7` which doesn't have a corresponding package set in nixpkgs (as of 2016-12-19).
2. Call Stack to expose the problem, e.g. `stack --nix build`
### Expected
A message which explains the problem, and gives actionable suggestions, for example:
```
$ stack --nix build
The following Nix expression failed to evaluate: 'haskell.packages.lts-7_7.ghc`. The message from Nix was:
error: attribute ‘lts-7_7’ missing, at (string):1:239
(use ‘--show-trace’ to show detailed location information)
$ stack --nix --show-trace build
The following Nix expression failed to evaluate: 'haskell.packages.lts-7_7.ghc'. The message from Nix was:
error: while evaluating the attribute ‘nativeBuildInputs’ of the derivation ‘shell’ at /nix/store/plh93kdk20fdb8vshd68jbijgvxx1mg0-nixos-16.09.1272.81428dd/nixos/pkgs/build-support/trivial-builders.nix:10:14:
while evaluating ‘getOutput’ at /nix/store/plh93kdk20fdb8vshd68jbijgvxx1mg0-nixos-16.09.1272.81428dd/nixos/lib/attrsets.nix:453:23, called from undefined position:
while evaluating the attribute ‘packages.lts-7_7.ghc’ at /home/chris/.nixpkgs/custom/haskell.nix:55:5:
attribute ‘lts-7_7’ missing, at (string):1:66
```
### Actual
There is no indication that the error is from Nix, and it is very terse:
```
$ stack --nix build
error: attribute ‘lts-7_7’ missing, at (string):1:239
(use ‘--show-trace’ to show detailed location information)
```
The suggestion to use `--show-trace` is coming from Nix, as its commands accept that option. The `stack` command doesn't:
```
$ stack --nix --show-trace build
Invalid option `--show-trace'
Usage: stack [--help] [--version] [--numeric-version] [--docker*] [--nix*]
([--verbosity VERBOSITY] | [-v|--verbose]) [--work-dir WORK-DIR]
[--[no-]system-ghc] [--[no-]install-ghc] [--arch ARCH] [--os OS]
[--ghc-variant VARIANT] [-j|--jobs JOBS] [--extra-include-dirs DIR]
[--extra-lib-dirs DIR] [--[no-]skip-ghc-check] [--[no-]skip-msys]
[--local-bin-path DIR] [--[no-]modify-code-page]
[--resolver RESOLVER] [--compiler COMPILER] [--[no-]terminal]
[--stack-yaml STACK-YAML] COMMAND|FILE
```
One quick way to improve this situation is to always use the `--show-trace` option (or equivalent if it's a library call) when invoking Nix. Alternatively, have `stack` accept this option and pass it through.
### Stack version
```
$ stack --version
Version 1.0.2 i386
```
Note: I tried for *many* hours to get 1.0.3 to install, but gave up.
### Method of installation
NixOS package
Contributor guide
Assessment
This issue has not been assessed yet.