Skip to content

Unable to start HIE Server on Mac OS X, get "ghc command not found" #126

Closed

Description

@ianbrault

I get the following issue when attempting to open a Haskell project folder in VS Code on Mac OS X 10.14:

2018-12-12 10:24:12.024134 [ThreadId 4] - Using plain GHC version
/bin/sh: ghc: command not found
hie: readCreateProcess: ghc --numeric-version (exit 127): failed
[Info  - 10:24:12 AM] Connection to server got closed. Server will restart.
2018-12-12 10:24:12.066354 [ThreadId 4] - Using plain GHC version
/bin/sh: ghc: command not found
hie: readCreateProcess: ghc --numeric-version (exit 127): failed
[Info  - 10:24:12 AM] Connection to server got closed. Server will restart.
2018-12-12 10:24:12.100128 [ThreadId 4] - Using plain GHC version
/bin/sh: ghc: command not found
hie: readCreateProcess: ghc --numeric-version (exit 127): failed
[Info  - 10:24:12 AM] Connection to server got closed. Server will restart.
2018-12-12 10:24:12.135374 [ThreadId 4] - Using plain GHC version
/bin/sh: ghc: command not found
hie: readCreateProcess: ghc --numeric-version (exit 127): failed
[Info  - 10:24:12 AM] Connection to server got closed. Server will restart.
2018-12-12 10:24:12.169213 [ThreadId 4] - Using plain GHC version
/bin/sh: ghc: command not found
hie: readCreateProcess: ghc --numeric-version (exit 127): failed
[Error - 10:24:12 AM] Connection to server got closed. Server will not be restarted.

The project was created using stack new and can build successfully with stack build.

I do not get a similar issue when I run hie in the workspace (hie is on my $PATH):

2018-12-12 10:26:00.863747 [ThreadId 4] - Using stack GHC version
2018-12-12 10:26:01.439648 [ThreadId 4] - Run entered for HIE(hie) Version 0.4.0.1, Git revision df6da6308fb5de672ad82ed5cb4dfeb91050d052 (dirty) (2218 commits) x86_64 ghc-8.6.2
2018-12-12 10:26:01.447437 [ThreadId 4] - Current directory:/Users/ianbrault/code/haskell/io

nor attempting to run with hie-wrapper (also on my $PATH):

2018-12-12 10:26:59.152784 [ThreadId 4] - run entered for hie-wrapper(hie-wrapper) Version 0.4.0.1, Git revision df6da6308fb5de672ad82ed5cb4dfeb91050d052 (dirty) (2218 commits) x86_64 ghc-8.6.2
2018-12-12 10:26:59.164961 [ThreadId 4] - Current directory:/Users/ianbrault/code/haskell/io
2018-12-12 10:27:00.31076 [ThreadId 4] - Cradle directory:/Users/ianbrault/code/haskell/io
2018-12-12 10:27:00.311226 [ThreadId 4] - Using stack GHC version
2018-12-12 10:27:00.488775 [ThreadId 4] - Project GHC version:8.6.2
2018-12-12 10:27:00.489596 [ThreadId 4] - hie exe candidates :["hie-8.6.2","hie-8.6","hie"]
2018-12-12 10:27:00.490847 [ThreadId 4] - found hie exe at:/usr/local/bin/hie-8.6.2
2018-12-12 10:27:00.491539 [ThreadId 4] - args:[]
2018-12-12 10:27:00.491991 [ThreadId 4] - launching ....



2018-12-12 10:27:00.751399 [ThreadId 4] - Using stack GHC version
2018-12-12 10:27:00.949176 [ThreadId 4] - Run entered for HIE(hie-8.6.2) Version 0.4.0.1, Git revision df6da6308fb5de672ad82ed5cb4dfeb91050d052 (dirty) (2218 commits) x86_64 ghc-8.6.2
2018-12-12 10:27:00.96506 [ThreadId 4] - Current directory:/Users/ianbrault/code/haskell/io

Versions of all tools:

  • ghc: The Glorious Glasgow Haskell Compilation System, version 8.6.2
  • stack: Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1
  • hie: Version 0.4.0.1, Git revision df6da6308fb5de672ad82ed5cb4dfeb91050d052 (dirty) (2218 commits) x86_64 ghc-8.6.2
  • hie-wrapper: Version 0.4.0.1, Git revision df6da6308fb5de672ad82ed5cb4dfeb91050d052 (dirty) (2218 commits) x86_64 ghc-8.6.2
  • note: the HIE scripts were downloaded from the pre-built Mac binaries provided by the latest release

This is my $PATH: /Users/ianbrault/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ianbrault/.local/bin:/usr/local/texlive/2017/bin/x86_64-darwin:/Library/TeX/texbin, all of the above binaries are installed in /usr/local/bin

I have seen several other issues where the users get a similar /bin/sh: ghc: command not found error message but I have attempted all the suggested fixes in those issues and have not been able to resolve the problem, specifically:

  • setting languageServerHaskell.hieExecutablePath to point directly at the hie binary
  • setting languageServerHaskell.useCustomHieWrapper to true and setting languageServerHaskell.useCustomHieWrapperPath to point directly at the hie-wrapper binary
  • symlinking hie-wrapper to be the hie binary
  • running stack update and stack upgrade
  • I have also tried setting the resolver to specifically target ghc-8.6.2 but still get the same errors

Please let me know if there's any more information that would be useful! Thanks

Activity

  1. 2mol commented on Dec 13, 2018

    @2mol

    Thanks for the detailed case! I will try to reproduce this on my own system and report back. Some (possibly random) notes:

    • Where did you install the ghc binary from?
    • which resolver are you using in your stack.yaml?
    • did you install cabal via stack as mentioned in the release page?
  2. 2mol commented on Dec 13, 2018

    @2mol

    Ok, I managed to also not have it work, so that's some progress. Some steps I took to narrow down the problem:

    • make sure to do stack install cabal-install
    • vscode settings: manually set the path for hie-wrapper in vscode, because it would otherwise guess ghc 8.6.2 for a 8.4.4 project (I'm guessing it uses the hie executable instead of the hie-wrapper one. We should help clarify that in the documentation once we solve this problem)
    • vscode settings: disable hlint, because it would complain about hlint.yaml not being found.
    • look at the logs under something like ~/Library/Application Support/Code/logs/20181213T120113/exthost1/output_logging_20181213T120116.

    It took me a really long time to find the logs, maybe you have a better way of getting them? Nevermind, I only now realized that you can conveniently select any log in the OUTPUT pane of vscode.

    Long story short, in my opinion the error message in the logs don't always relate to the actual problem. I now have this:

    hie-8.4.4: Could not find $libexecdir/cabal-helper-wrapper
    
    If you are a cabal-helper developer you can set the environment variable
    `cabal_helper_libexecdir' to override $libexecdir[1]. The following will
    work in the cabal-helper source tree:
    
        $ export cabal_helper_libexecdir=$PWD/dist/build/cabal-helper-wrapper
    
    [1]: /Users/luke/Source/haskell-ide-engine/.stack-work/install/x86_64-osx/lts-12.20/8.4.4/libexec/x86_64-osx-ghc-8.4.4/cabal-helper-0.9.0.0
    /Users/luke/Source/haskell-ide-engine/.stack-work/install/x86_64-osx/lts-12.20/8.4.4/libexec/x86_64-osx-ghc-8.4.4/cabal-helper-0.9.0.0/cabal-helper-wrapper
    junk/build/cabal-helper-wrapper/cabal-helper-wrapper
    /Users/luke/Source/haskell-ide-engine/.stack-work/install/x86_64-osx/lts-12.20/8.4.4/bin/cabal-helper-wrapper
    ...
    

    Notice the path above that says luke. My guess is that something got hardcoded when the release was compiled? I will remove that hie and compile my own to compare.

  3. jneira commented on Jan 9, 2020

    @jneira
    Member

    hie not longer uses cabal-helper-wrapper and it is able to start using stack if there is no ghc on path so i think this should be fixed: @ianbrault @2mol feel free to reopen if it is not the case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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