Please follow the steps below for reporting a bug:
Make sure that you are using the latest release (currently stack-1.9.3).
See the upgrade instructions to upgrade.
Please use the following schema for your bug report:
LTS-9.21 requires ghc-8.0.2 which is not available in current nixpkgs.
nix-shell -p stack
stack unpack transformers
cd transformers
cat >stack.yaml <<< "resolver: 9.32"
stack build
It would be nice if Stack would fall back to installing ghc-8.0.2 as it does on other platforms. If that's too hard, an error message saying something like "resolver 9.21 requires ghc-8.0.2. your
error: attribute 'ghc802' missing, at (string):1:43
(use '--show-trace' to show detailed location information)
$ stack --version
1.9.3 x86_64 hpack-0.31.1
nix-shell -p stack
@nh2 Can you take a look at this? I'm not sure what ought to happen.
@dbaynard I think the simple first step would be to catch the error and provide a more useful explanation to the user. As @duog pointed out, a simple message like the following would be really helpful:
resolver 9.21 requires ghc-8.0.2. your does not have a derivation for this version, probably because it's too old. Sorry.
Do we know where the relevant code is?
Perhaps it should be some form of wrapper around getCompilerVersion from
?
IMO if stack insists on using this wrapper then it should pin the version of nixpkgs (for the GHC version) rather than using the system nixpkgs.
Are there any workarounds/tips for this? It's difficult to configure IDE tools etc to use --no-nix, system-ghc, etc. I have the latest stack (1.9.3). I don't think the solutions here helped either: https://github.com/commercialhaskell/stack/issues/4196.
EDIT: a workaround that fixed it for me temporarily is adding the following lines to ~/.stack/config.yaml, but that doesn't work for builds that require nix packages like zlib:
system-ghc: true
nix:
enable: false
@maxkrieger I suppose you may install older GHC from @mpickering 's repo - https://discourse.nixos.org/t/new-nur-repo-for-ghc-binaries/2660 and then you should be ablo to use nix mode
@qrilka I don't think it helped, here's my attempt:
~/.stack/config.yaml:
system-ghc: true
nix:
enable: true
pure: true
packages: [llvm, zlib, ncurses, ghc]
add-gc-roots: true
~$ nix-env -e ghc-8.0.2-binary
~$ nix-env -iA nixpkgs.nur.repos.mpickering.ghc.ghc802
~$ cd myProject/
myProject/$ stack build
error: attribute 'ghc802' missing, at (string):1:65
(use '--show-trace' to show detailed location information)
Alternatively, through nix-shell:
myProject/$ nix-shell -p nur.repos.mpickering.ghc.ghc802 stack zlib
> ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.0.2
> stack build
error: attribute 'ghc802' missing, at (string):1:65
(use '--show-trace' to show detailed location information)
@maxkrieger sorry for that incorrect assumption, I should have tried it first. The situation is a bit more complicated actually but it looks like there is a workaround: use a custom shell.nix file.
E.g. on my laptop I have NixOS 18.09 and it looks to contain the main latest GHC versions, so I tried not that widely used 8.4.1 and with the following shell.nix:
with (import <nixpkgs> {});
let ghc = nur.repos.mpickering.ghc.ghc841;
in haskell.lib.buildStackProject {
inherit ghc;
name = "myEnv";
buildInputs = [ pcre ];
}
I get:
stack-1.9.3 --nix-shell-file=shell.nix exec -- ghc --version
and building also appears to work.
The main problem here is that you need to map properly GHC version in your stack.yaml and in shell.nix. Without a shell file that's done automatically but that method relies on GHC being available from nixpkgs.
BTW there is an alternative method - you could just add nur.repos.mpickering.ghc.ghc841 as nixpkgs.haskell.compiler.ghc841 in your configuration.nix. With that you won't need shell.nix
@qrilka Thanks so much, your shell solution worked--couldn't quite deduce the syntax for "adding" the repo "as" the compiler package.
Also, what makes GHC unavailable from nixpkgs? I can install haskell.compiler.ghc802 just fine. Is it a naming mismatch?
@maxkrieger the idea is to add missing attribute from Mathew's repo. Without knowing details of your setup I can't say for sure why it's missing. Example scenario is that you could use unstable channel or the recently released 19.0.3 which don't include this version, e.g. see https://github.com/NixOS/nixpkgs-channels/blob/nixos-unstable/pkgs/top-level/haskell-packages.nix
At the same time I don't quite understand how could you install haskell.compiler.ghc802 (as you're saying it above) if it's not supposed to be available
Most helpful comment
IMO if stack insists on using this wrapper then it should pin the version of nixpkgs (for the GHC version) rather than using the system nixpkgs.