-
Notifications
You must be signed in to change notification settings - Fork 842
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
Stack on nixos fails when ghc not available in nixpkgs, e.g. ghc802 #4539
Comments
@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:
Do we know where the relevant code is? |
Perhaps it should be some form of wrapper around Line 64 in 217fa42
? |
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 EDIT: a workaround that fixed it for me temporarily is adding the following lines to 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:
system-ghc: true
nix:
enable: true
pure: true
packages: [llvm, zlib, ncurses, ghc]
add-gc-roots: true
Alternatively, through
|
@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
I get:
and building also appears to work. |
@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 |
@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 |
The error here should report what the user needs to do as it's pretty common to happen. |
@domenkozar thank you for raising that point, I wholeheartedly agree! @qrilka, I would be happy to help with the update to error messaging, but would probably need some guidance on what changes to make. |
@ketzacoatl I think what's needed here is adding some hints when error comes from |
@qrilka I see that uses |
Sorry for a late reply, yes, I suppose we'll need to use something like |
Is this part from nix? I was very confused when I attempted to re-run stack with the --show-trace flag and it didn't exist.
It seems like defaulting to Nix mode is maybe not a good idea if a simple I think the default should probably be act as usual with the ability to opt in to using Nix. At the very least until |
I'm having the same issue running ~ % nix-shell -p ghc stack cabal-install # all from stable
[nix-shell:~]$ stack new hello-world
error: attribute 'ghc8107' missing, at (string):1:43
(use '--show-trace' to show detailed location information) As of the time of writing, the This is my hunch on what I think happened under the hood:
The following workaround worked for me: # ~/.stack/config.yaml
nix:
enable: false No need to use It seems like the core problem is that Stack is hardcoded to use whatever version of GHC Stack things should be available when running into Stack seems to enable nix-mode automatically when it detects NixOS. Lines 39 to 41 in 255cd83
While I think that the above can be appropriate. I agree with @sullyj3's suggestion that it is rather confusing to have this be default when The "proper" workaround to enable nix mode would be to create a A solution I can think of for this would be to allow a way to optionally version-lock the |
As a note, it's also a problem with Nix outside NixOS. With this in nix:
enable: true
pure: true I also had this error when trying to create a new project (or trying to build exisitng projects): pierre:~$ stack new example
error: attribute 'ghc8104' missing, at (string):1:43
(use '--show-trace' to show detailed location information) I had to disable nix in with import (fetchTarball https://github.com/NixOS/nixpkgs/archive/c4ed2a618c5f8b51c1be5983c9c2e662d76679ad.tar.gz) {};
let ghc = haskell.compiler.ghc8106;
in haskell.lib.buildStackProject {
inherit ghc;
name = "example";
src = ./.;
} |
None of these work arounds have worked for me. Is this still being investigated? |
specifying nixpkgs with
|
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:
General summary/comments (optional)
LTS-9.21 requires ghc-8.0.2 which is not available in current nixpkgs.
Steps to reproduce
Expected
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 does not have a derivation for this version, probably because it's too old. Sorry."
Actual
Stack version
Method of installation
nix-shell -p stack
The text was updated successfully, but these errors were encountered: