Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Only see 'latest' target in help text #1620

Closed
kozross opened this issue Jan 30, 2020 · 6 comments · Fixed by #1632
Closed

Only see 'latest' target in help text #1620

kozross opened this issue Jan 30, 2020 · 6 comments · Fixed by #1632
Labels
build Continuous integration and building os: linux type: enhancement

Comments

@kozross
Copy link

kozross commented Jan 30, 2020

I was trying to install HIE today. The log shows best what happened.

[koz@Sebastian ~]$ git clone /~https://github.com/haskell/haskell-ide-engine --recurse-submodules
Cloning into 'haskell-ide-engine'...
remote: Enumerating objects: 117, done.
remote: Counting objects: 100% (117/117), done.
remote: Compressing objects: 100% (82/82), done.
remote: Total 27267 (delta 53), reused 57 (delta 16), pack-reused 27150
Receiving objects: 100% (27267/27267), 6.48 MiB | 4.08 MiB/s, done.
Resolving deltas: 100% (14593/14593), done.
[koz@Sebastian ~]$ cd haskell-ide-engine/
[koz@Sebastian haskell-ide-engine]$ cabal new-run -w /home/koz/ghc-88/bin/ghc ./install.hs --project-file install/shake.project help
Resolving dependencies...
Build profile: -w ghc-8.8.1 -O1
In order, the following will be built (use -v for more details):
 - hie-install-0.8.0.0 (lib) (first run)
 - fake-package-0 (exe:script) (first run)
Configuring library for hie-install-0.8.0.0..
Preprocessing library for hie-install-0.8.0.0..
Building library for hie-install-0.8.0.0..
[1 of 8] Compiling BuildSystem      ( src/BuildSystem.hs, /home/koz/haskell-ide-engine/dist-newstyle/build/x86_64-linux/ghc-8.8.1/hie-install-0.8.0.0/build/BuildSystem.o )
[2 of 8] Compiling Print            ( src/Print.hs, /home/koz/haskell-ide-engine/dist-newstyle/build/x86_64-linux/ghc-8.8.1/hie-install-0.8.0.0/build/Print.o )
[3 of 8] Compiling Version          ( src/Version.hs, /home/koz/haskell-ide-engine/dist-newstyle/build/x86_64-linux/ghc-8.8.1/hie-install-0.8.0.0/build/Version.o )
[4 of 8] Compiling Env              ( src/Env.hs, /home/koz/haskell-ide-engine/dist-newstyle/build/x86_64-linux/ghc-8.8.1/hie-install-0.8.0.0/build/Env.o )
[5 of 8] Compiling Stack            ( src/Stack.hs, /home/koz/haskell-ide-engine/dist-newstyle/build/x86_64-linux/ghc-8.8.1/hie-install-0.8.0.0/build/Stack.o )
[6 of 8] Compiling Cabal            ( src/Cabal.hs, /home/koz/haskell-ide-engine/dist-newstyle/build/x86_64-linux/ghc-8.8.1/hie-install-0.8.0.0/build/Cabal.o )
[7 of 8] Compiling Help             ( src/Help.hs, /home/koz/haskell-ide-engine/dist-newstyle/build/x86_64-linux/ghc-8.8.1/hie-install-0.8.0.0/build/Help.o )
[8 of 8] Compiling HieInstall       ( src/HieInstall.hs, /home/koz/haskell-ide-engine/dist-newstyle/build/x86_64-linux/ghc-8.8.1/hie-install-0.8.0.0/build/HieInstall.o )
Configuring executable 'script' for fake-package-0..
Preprocessing executable 'script' for fake-package-0..
Building executable 'script' for fake-package-0..
[1 of 1] Compiling Main             ( Main.hs, /home/koz/haskell-ide-engine/dist-newstyle/build/x86_64-linux/ghc-8.8.1/fake-package-0/x/script/build/script/script-tmp/Main.o )
Linking /home/koz/haskell-ide-engine/dist-newstyle/build/x86_64-linux/ghc-8.8.1/fake-package-0/x/script/build/script/script ...

Usage:
    stack install.hs <target>
    or
    cabal v2-run install.hs --project-file install/shake.project <target>

Targets:
    help                Show help message including all targets

    hie                 Install hie with the latest available GHC and the data files
    latest              Install hie with the latest available GHC
    data                Get the required data-files for `hie` (Hoogle DB)

    ghcs                Show all GHC versions that can be installed via `cabal-build`.

    icu-macos-fix       Fixes icu related problems in MacOS

Build completed in 0.00s

I can't see any targets except latest. Is this a bug, or am I missing something?

@jneira
Copy link
Member

jneira commented Jan 31, 2020

The install.hs script looks for ghc executables in $PATH following the convention ghc-${version}, and the default ghc installation has a executable with that name schema. The other requirement is that a stack-${ghcVersion}.yaml should be in hie main dir. Otoh versions ghc-8.8.1 and ghc-8.8.2 are not usable in windows (but it seems you are on linux).
If both requirements are fullfilled it must list hie-8.8.1, the ghc you are using, so it is a little bit weird.

That is the output in my win system:

D:\ws\haskell\haskell-ide-engine>cabal-hie-install ghcs
Building the script
********************************************************************************
Found the following GHC paths:
ghc-8.4.4: D:\bin\Programs\stack\x86_64-windows\ghc-8.4.4\bin\ghc-8.4.4.exe
ghc-8.6.4: D:\bin\Programs\stack\x86_64-windows\ghc-8.6.4\bin\ghc-8.6.4.exe
ghc-8.6.5: D:\bin\Programs\stack\x86_64-windows\ghc-8.6.5\bin\ghc-8.6.5.exe

********************************************************************************

Build completed in 0.02s
D:\ws\haskell\haskell-ide-engine>cabal-hie-install help
...............
Usage:
    stack install.hs <target>
    or
    cabal v2-run install.hs --project-file install/shake.project <target>

Targets:
    help                Show help message including all targets

    hie                 Install hie with the latest available GHC and the data files
    latest              Install hie with the latest available GHC
    data                Get the required data-files for `hie` (Hoogle DB)
    hie-8.4.4           Install hie for GHC version 8.4.4
    hie-8.6.4           Install hie for GHC version 8.6.4
    hie-8.6.5           Install hie for GHC version 8.6.5

    ghcs                Show all GHC versions that can be installed via `cabal-build`.

    icu-macos-fix       Fixes icu related problems in MacOS

Build completed in 0.04s

EDIT: i've just spotted the -w /home/koz/ghc-88/bin/ghc of your command. I am afraid that the install script are assuming the ghc(s) are in path, following the convention (used by ghcup f.e.) that you add all availables ghcs in path, prepending your preferred one to use it simply with ghc.
Then cabal commands for alternative ghcs usually are: cabal command -w ghc-${version}

So the ghc used to run the script and the ghc used to install hie can be different.

@kozross
Copy link
Author

kozross commented Jan 31, 2020

So how should I then use the install script in my case? Just pick latest? Does this mean that the resulting HIE would work against the GHC I passed with -w?

@kozross
Copy link
Author

kozross commented Jan 31, 2020

Also, when I tried the hie target, I got this:

[koz@Emi haskell-ide-engine]$ cabal new-run -w /home/koz/ghc-88/bin/ghc ./install.hs --project-file install/shake.project hie
Resolving dependencies...
Build profile: -w ghc-8.8.2 -O1
In order, the following will be built (use -v for more details):
 - fake-package-0 (exe:script) (configuration changed)
Configuring executable 'script' for fake-package-0..
Preprocessing executable 'script' for fake-package-0..
Building executable 'script' for fake-package-0..
[1 of 1] Compiling Main             ( Main.hs, /home/koz/haskell-ide-engine/dist-newstyle/build/x86_64-linux/ghc-8.8.2/fake-package-0/x/script/build/script/script-tmp/Main.o )
Linking /home/koz/haskell-ide-engine/dist-newstyle/build/x86_64-linux/ghc-8.8.2/fake-package-0/x/script/build/script/script ...
Error when running Shake build system:
  at want, called at src/Development/Shake/Internal/Args.hs:83:69 in shake-0.18.4-7f9bbcf2493dbc2db46e30ab4e42e1ac58ec0e14c5725b2c6dcbf00ea205c199:Development.Shake.Internal.Args
* Depends on: hie
  at apply1, called at src/Development/Shake/Internal/Rules/Rerun.hs:41:5 in shake-0.18.4-7f9bbcf2493dbc2db46e30ab4e42e1ac58ec0e14c5725b2c6dcbf00ea205c199:Development.Shake.Internal.Rules.Rerun
* Depends on: latest
* Raised the exception:
Prelude.last: empty list

I'm assuming this is because I have my GHCs not where ghcup would put them? Given that as far as I know, ghcup is unable to provide LLVM versions to go with its compilers (the reason I've done it manually like I have is not least of all that), which makes me basically unable to use HIE, or even install it.

@jneira
Copy link
Member

jneira commented Jan 31, 2020

I'm assuming this is because I have my GHCs not where ghcup would put them?

Not exactly, the script assumes that ghc is in $PATH, it should work simply adding to it. I only mentioned ghcup cause it follows the convention of adding ghcs to $PATH.

> export PATH=/path/to/ghc/bin:$PATH
> ./cabal-hie-install latest

should work

That said, the Prelude.last: empty list is not user friendly, it should show a message warning telling that ghc should be in path

@nponeccop
Copy link
Contributor

nponeccop commented Feb 1, 2020

Prelude.last: empty list is not user friendly, it should show a message

I wonder if Safe.lastNote would be sufficient

And for local environment changes the following also works, but it doesn't pollute current shell:

PATH=/path/to/ghc/bin:$PATH ./cabal-hie-install latest

@kozross
Copy link
Author

kozross commented Feb 9, 2020

I can confirm that the suggested PATH-based approaches work correctly. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
build Continuous integration and building os: linux type: enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants