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

stack ghci invokes all subprojects listed in stack.yaml #1296

Closed
fosskers opened this issue Apr 22, 2016 · 6 comments
Closed

stack ghci invokes all subprojects listed in stack.yaml #1296

fosskers opened this issue Apr 22, 2016 · 6 comments

Comments

@fosskers
Copy link

fosskers commented Apr 22, 2016

I discovered this when attempting to haskell-process-load-file (C-c C-l) in a subproject. My project has a single stack.yaml at top-level, with three subprojects, all with their own .cabal. Now, in one of those .cabal I defined default-extensions: NoImplicitPrelude for convenience. To my surprise, when I tried to C-c C-l in one of the other subprojects, the compiler complained of missing symbols, as if NoImplicitPrelude were defined there as well.

Checking the *haskell-process-log*, I found:

("Starting inferior stack GHCi process using stack" "aur" nil "stack" "ghci" "--ghc-options=-ferror-spans")
...
There are issues with this project which may prevent GHCi from working properly.

   -XNoImplicitPrelude will be used, but GHCi will likely fail to build things which depend on the implicit prelude.

   It is specified for:

       aura:exe:aura

   But not for: 

       arel:exe:arel aur:lib
...

which is what one sees when they invoke stack ghci manually from the command line in such a project. However, haskell-mode goes on to just load all the subprojects and their settings, even though I intended to only be working with one of them:

Configuring GHCi with the following packages: arel, aur, aura

Note that none of this happens on the command line if you are explicit about the subproject from the get-go: stack ghci aur.

This tells me that haskell-mode isn't invoking stack ghci correctly.

@gracjan
Copy link
Contributor

gracjan commented Apr 22, 2016

haskell-mode runs ghci as:

stack ghci

you seem to want:

stack ghci aur

@fosskers
Copy link
Author

Precisely. If run as stack ghci <name-of-subproject-here> we would avoid the settings-pollution bug that we're seeing.

The name-of-subproject should be an available symbol at ghci invocation time, as the REPL buffer's name is always that of the subproject.

@mgsloan
Copy link

mgsloan commented Apr 22, 2016

stack ghci takes all the same target syntax as stack build, including directories (all packages contained in the dir are built). So, you could also do stack ghci path/to/my-pkg/. This will likely be easier, if haskell-mode knows the cabal file associated with the hs file you're starting ghci for

@fosskers
Copy link
Author

haskell-mode does know the local cabal file, as well as the top-level stack file. Since I have:

packages:
  - aura/
  - aur/
  - arel/

listed in my stack.yaml, it shouldn't have trouble finding only the subproject I'm trying to invoke the REPL for.

@mgsloan
Copy link

mgsloan commented Apr 23, 2016

Right, the issue is that haskell-mode probably won't know the cabal package name. It will know its directory, though.

@fosskers
Copy link
Author

I think it does know the cabal package name. Anecdote tells me at much, at least.

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

No branches or pull requests

3 participants