Skip to content

Failure to start hie when cabal-install is installed #165

Closed
@GuillaumeDesforges

Description

@GuillaumeDesforges

Hello

Stack trace

Child process fails on
/nix/store/a1fgqywyav0dkmk3kkq3hm8219aas6cw-cabal-helper-0.9.0.0/bin/cabal-helper-wrapper "--with-ghc=ghc" "--with-ghc-pkg=ghc-pkg" "--with-cabal=cabal" "v1-style" "/home/arsleust/projects/test-project" "/home/arsleust/projects/test-project/dist" "package-db-stack" "flags" "compiler-version" "ghc-merged-pkg-options" "config-flags" "non-default-config-flags" "ghc-src-options" "ghc-pkg-options" "ghc-lang-options" "ghc-options" "source-dirs" "entrypoints" "needs-build-output"

Setup

I am on NixOS and I use the following setup :

generated.nix : generated by cabal2nix, contains GHC and Haskell packages
                                 | (derivation)
                                \ /
   default.nix : I add custom build tools, especially non-Haskell packages
                                 |
                                \ /
                dev.nix : from which I start VS Code

default.nix

let
  pkgs = import <nixpkgs> {};
  generatedDrv = import ./generated.nix {};
in
  generatedDrv.overrideAttrs (generated: {
    buildInputs = generated.buildInputs ++ [
      ## Put additional packages here
    ];
  })

dev.nix

let
  pkgs = import <nixpkgs> {};
  defaultDrv = import ./default.nix;
  all-hies = import (fetchTarball "https://github.com/infinisil/all-hies/tarball/master") {};
  hie = all-hies.selection { selector = p: { inherit (p) ghc864; }; };
  wrapped-vscode = pkgs.runCommand "${pkgs.vscode.name}" {nativeBuildInputs = [ pkgs.makeWrapper ]; } ''
    mkdir -p $out/bin
    makeWrapper ${pkgs.vscode}/bin/code $out/bin/code --prefix PATH : ${pkgs.lib.makeBinPath [hie]}
  '';
in
  defaultDrv.overrideAttrs (default: {
    buildInputs = default.buildInputs ++ [
      ## Put additional DEV packages here
      pkgs.cabal-install
      pkgs.haskellPackages.hoogle
      wrapped-vscode
    ];
  })

Everything works good if I remove the pkgs.cabal-install above, except the warning that cabal-install is not found (and that I should read README).

Investigation

I tried to run in nix-shell the command:

[nix-shell:~/projects/test-project]$ /nix/store/a1fgqywyav0dkmk3kkq3hm8219aas6cw-cabal-helper-0.9.0.0/bin/cabal-helper-wrapper "--with-ghc=ghc" "--with-ghc-pkg=ghc-pkg" "--with-cabal=cabal" "v1-style" "/home/arsleust/projects/test-project" "/home/arsleust/projects/test-project/dist" "package-db-stack" "flags" "compiler-version" "ghc-merged-pkg-options" "config-flags" "non-default-config-flags" "ghc-src-options" "ghc-pkg-options" "ghc-lang-options" "ghc-options" "source-dirs" "entrypoints" "needs-build-output"
cabal-helper-wrapper: Installing a private copy of Cabal because we couldn't
find the right version in your global/user package-db, this might take a
while but will only happen once per Cabal version you're using.

If anything goes horribly wrong just delete this directory and try again:
    /home/arsleust/.cache/cabal-helper

If you want to avoid this automatic installation altogether install
version 2.4.1.0 of Cabal manually (into your user or global package-db):
    $ cabal install Cabal --constraint "Cabal == 2.4.1.0"

Installing Cabal 2.4.1.0 ...
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
cabal: There is no package named 'Cabal'.
You may need to run 'cabal update' to get the latest list of available
packages.

cabal-helper-wrapper: Installing Cabal version 2.4.1.0 failed.

You have the following choices to fix this:

- The easiest way to try and fix this is just reconfigure the project and try
  again:
        $ cabal clean && cabal configure

- If that fails you can try to install the version of Cabal mentioned above
  into your global/user package-db somehow, you'll probably have to fix
  something otherwise it wouldn't have failed above:
        $ cabal install Cabal --constraint 'Cabal == 2.4.1.0'

- If you're using `Build-Type: Simple`:
  - You can see if you can reinstall your cabal-install executable while
    having it linked to a version of Cabal that's available in you
    package-dbs or can be built automatically:
        $ ghc-pkg list | grep Cabal  # find an available Cabal version
            Cabal-W.X.Y.Z
        $ cabal install cabal-install --constraint 'Cabal == W.X.*'
    Afterwards you'll have to reconfigure your project:
        $ cabal clean && cabal configure

- If you're using `Build-Type: Custom`:
  - Have cabal-install rebuild your Setup.hs executable with a version of the
    Cabal library that you have available in your global/user package-db:
        $ cabal clean && cabal configure
    You might also have to install some version of the Cabal to do this:
        $ cabal install Cabal

This definitly shouldn't make the HIE crash.

My questions are :

  • is the extension crashing, or is it HIE ?
  • should it really crash for this ?
  • could a cabal update fix this ?

I'm a bit new to all this, so I might be completly wrong, ut anyway thanks for your time !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions