Skip to content
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

ghcide not starting for stack projects with docker enabled builds #1037

Closed
mariatsji opened this issue Dec 5, 2019 · 7 comments
Closed

ghcide not starting for stack projects with docker enabled builds #1037

mariatsji opened this issue Dec 5, 2019 · 7 comments

Comments

@mariatsji
Copy link

Steps to reproduce:

Run a stack build with a stack.yaml containing

packages:
- .
docker:
  enable: true
resolver: lts-14.14

now running ghcide results in (I had to retry this command due to some docker-pull in the background that gave a different error message)

ghcide                                                                                                                            1
ghcide version: 0.0.4 (GHC: 8.6.5)
Ghcide setup tester in /Users/sjumilli/haskell/stackdocker.
Report bugs at https://github.com/digital-asset/ghcide/issues

Step 1/6: Finding files to test in /Users/sjumilli/haskell/stackdocker
Found 3 files

Step 2/6: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/6, Cradle 1/1: Implicit cradle for /Users/sjumilli/haskell/stackdocker
Cradle {cradleRootDir = "/Users/sjumilli/haskell/stackdocker", cradleOptsProg = CradleAction: stack}

Step 4/6, Cradle 1/1: Loading GHC Session
ghcide: (ExitFailure 1,"","")
CallStack (from HasCallStack):
  error, called at src/HIE/Bios/Cradle.hs:299:18 in hie-bios-0.2.1-CpNUPrWjqiyHklKCc1nhUy:HIE.Bios.Cradle```
@ndmitchell
Copy link
Collaborator

This seems an issue with hie-bios rather than ghcide, since it gets ExitFailure when it tries to load the session. CC @mpickering

@mpickering
Copy link
Contributor

How does stack's docker integration work? Does it mean that ghc is not on the user path anymore?

@mariatsji
Copy link
Author

Thank you for responding, guys.

I believe that with docker enabled stack builds, ghc is only available inside a spawned docker container, yes, and that one have to pass flags and params to ghc via stack commands, such as
stack runghc -- --no-ghc-package-path X.hs
or
stack run --docker-run-args='-e ENV=dev'

A small snippet from an 2015 fpcomplete-blog-post explaining the integration between stack and docker :

"When Docker is enabled in stack.yaml, every invocation of stack (with the exception of certain sub-commands) transparently re-invokes itself in an ephemeral Docker container which has the project root directory and the stack home (~/.stack) bind-mounted. The container exists only to provide the environment in which the build runs, nothing is actually written to the container's file-system (any writes happen in the bind-mounted directories) and it the container is destroyed immediately after stack exits (using docker run --rm)"

@mpickering
Copy link
Contributor

Should be fixed once haskell/hie-bios#97 is merged.

@mpickering
Copy link
Contributor

We looked into this a little (haskell/hie-bios#101) and came to the conclusion that it was out of scope for hie-bios because you really need to execute ghcide inside the container for anything to work. This is because all the installed packages and C libraries are only accessible from inside the container.

Therefore, you should use stack exec ghcide to run it inside the container and make sure ghcide is installed in the container.

@cocreature
Copy link
Contributor

Thanks for looking into that. I agree that this can’t be fixed in hie-bios. Setting the executable to stack exec ghcide seems like the best option here.

@mariatsji
Copy link
Author

That possibility never closed my mind, thanks!

@pepeiborra pepeiborra transferred this issue from haskell/ghcide Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants