Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Problem within repl in a stack project with multiple packages. #1243

Closed
meditans opened this issue Oct 27, 2015 · 6 comments
Closed

Problem within repl in a stack project with multiple packages. #1243

meditans opened this issue Oct 27, 2015 · 6 comments

Comments

@meditans
Copy link

Hi, I have three undesired behaviours when using a repl in a stack project which makes use of a package on github in the packages section (in my case, a modified version of the hint package).

Firstly, I get this behaviour with stack ghci, or using haskell-mode inside emacs: When loading the package (eg. stack ghci) I get a lot of errors like this one:

In file included from <command-line>:10:0: /home/meditans/code/haskell/provaHint/.stack-work/downloaded/0075423eecf6de8b6352671754046c16f71edae18522ac5564debf553494bcea.git/.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/cabal_macros.h:171:0: …
     warning: "CURRENT_PACKAGE_KEY" redefined
     #define CURRENT_PACKAGE_KEY "hint_KPuxWkEhUYP3oLnQwZzhof"
     ^

Secondly, inside emacs, I don't seem to be able to use ghc-mod, because of:

cannot satisfy -package-id hint-0.4.2.3-5d4875935ddea3fc0ae920904280faf4

Thirdly, as I am using a modified version of hint, a source code interpreter, the code of my program is unable to analyze imports outside of base, like Control.Lens, while the same program using the unmodified hint package could.

Is there a way to correct or mitigate these (probably interconnected) problems?

@mgsloan
Copy link
Contributor

mgsloan commented Oct 28, 2015

My guess is that this is caused by having cabal_macros.h from multiple packages. The best way to mitigate stuff like this is to run stack ghci on just one target. For example, stack ghci my-package:lib.

What's your stack version? Do these issues persist if you stack upgrade --git to use the current development version?

@PierreR
Copy link

PierreR commented Oct 28, 2015

I have the exact same problem when using a local package, though I cannot pinpoint exactly what triggers it.

@creichert
Copy link

I have this problem as well with no luck finding the root cause. It would be a big deal for my team if it was fixed since we have a hard time using ghci with stack at all. FWIW, the problematic project has a lot of git dependencies.

@mgsloan that suggestion works but is more difficult to use from an an editor (emacs). I think other issues arise when using stack ghci my-package:lib and trying to load files from another project.

I'll upgrade and try to provide some version numbers if the problem persists.

@mgsloan
Copy link
Contributor

mgsloan commented Oct 29, 2015

@creichert It might be helpful to put extra-dep: True on those git dependencies - see #1217

Most of the problems come from attempting to use ghci on multiple packages at once, which isn't really a very principled thing to do. See this ghc ticket on the subject: https://ghc.haskell.org/trac/ghc/ticket/10827

There may still be some bugs where stack could invoke ghci with a better options, but in general loading multiple packages / components is just something that can work, but there are numerous things that can break it.

The default behavior of stack ghci is to try to load everything, which is the most likely to not not work. Maybe stack ghci should just run ghci without loading any local packages.

For editor integration, maybe it would be useful to have stack ghci some/file/Path.hs, which will determine the cabal component to load based on the filepath.

@borsboom borsboom added this to the P2: Should milestone Nov 3, 2015
@meditans
Copy link
Author

meditans commented Nov 4, 2015

@mgsloan I was using the latest stack, and the issue persisted after the upgrade to the git version.

However, all my issues were fixed adding extra-dep: True. I didn't know about that option, I think it would be useful to add it in the Stack guide!

@mgsloan
Copy link
Contributor

mgsloan commented Nov 18, 2015

Sounds like everyone's problems are resolved, closing. Feel free to open other issues about this stuff.

@mgsloan mgsloan closed this as completed Nov 18, 2015
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

5 participants