You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cabal repl fails on package with Library and Executable #4602
I've been having the same issue ever since I installed Cabal v2, and my package does not even have executables. It only has a library and a test-suite.
A temporary workaround for this problem is to add a flag to your cabal that you can mark the executables as Buildable: false so that there is only one target left, the library. I didn't find a way to select the library only from the command line arguments, so I used this workaround.
First I added the flag above the targets in my cabal file:
Flag library-only
Default: False
Then I added a conditional for each target that check the flag, like this:
executable myapp
if flag(library-only)
Buildable: False
Then before running cabal repl I ran:
cabal configure -flibrary-only
Then I could successfully run cabal repl to only use the library 🥇
Reacted by Brian McKenna, George Ungureanu, onurcanbektas, Ben Anson and Gareth Clews
I have the same issue. The commands below work correctly cabal repl exe:<name> cabal repl test:<name>
however I cannot run cabal repl cabal: The 'repl' command does not support multiple targets at once.
OR cabal repl lib cabal: Unknown build target 'lib'.
But in cabal repl --help we can see
Examples:
cabal repl The first component in the package
cabal repl foo A named component (i.e. lib, exe, test suite)
So according to it lib COMPONENT should be valid target as well
@hvr I mean, only one public library is allowed to be defined per package. So when cabal repl is invoked, it would be nice to default to the public library.
While this ticket is about the soon to be obsolete (old)-repl semantics; things get a lot more interesting in the new-repl paradigm, where the decision which component to load needs to take into account a multi-package situation.
We have a related design issue with the semantics of which set of goals an implicit (i.e. w/o any explicit target selectors) cabal new-build expands into. There we currently default to using the package that's currently in $CWD as the implicit target goal; and if there isn't any package in the current $CWD, we ask the user to disambiguate.
This would naturally extend to an implicit cabal new-repl, which should pick a default goal if and only if there's an obvious and unique(!) choice inferrable from $CWD, and if it isn't unique, ask the user to disambiguate/clarify. A related design issue concerns cabal new-run which faces a similiar design issue (#4676). We should make sure that all these sub-design choices result in an overall consistent design of all new-* commands to reduce confusion.
Activity
michalrus commentedon Sep 11, 2017
This is inconsistent with
cabal repl --help:And it broke https://github.com/michalrus/intero-nix-shim. 😃 I’ll do a workaround there for the time being.
Add a workaround for haskell/cabal#4602
Add a workaround for haskell/cabal#4602
zcesur commentedon Sep 12, 2017
I've been having the same issue ever since I installed Cabal v2, and my package does not even have executables. It only has a library and a test-suite.
rzetterberg commentedon Nov 8, 2017
A temporary workaround for this problem is to add a flag to your cabal that you can mark the executables as
Buildable: falseso that there is only one target left, the library. I didn't find a way to select the library only from the command line arguments, so I used this workaround.First I added the flag above the targets in my cabal file:
Then I added a conditional for each target that check the flag, like this:
Then before running
cabal replI ran:Then I could successfully run
cabal replto only use the library 🥇kapralVV commentedon Jan 13, 2018
I have the same issue. The commands below work correctly
cabal repl exe:<name>cabal repl test:<name>however I cannot run
cabal replcabal: The 'repl' command does not support multiple targets at once.
OR
cabal repl libcabal: Unknown build target 'lib'.
But in
cabal repl --helpwe can seeSo according to it
libCOMPONENT should be valid target as wellmitchellwrosen commentedon Jan 20, 2018
@kapralVV This works:
dmjio commentedon Jun 5, 2018
Would be nice to just allow
cabal repl lib, since afaik only one lib is allowed.hvr commentedon Jun 5, 2018
@dmjio what do you mean by "only one lib is allowed"?
dmjio commentedon Jun 20, 2018
@hvr I mean, only one public library is allowed to be defined per package. So when
cabal replis invoked, it would be nice to default to the public library.dmjio commentedon Jun 20, 2018
@hvr, I suppose
cabal new-replhas this behavior.23Skidoo commentedon Jun 20, 2018
Note that this restriction will be going away soon (this is what @fgaz's GSoC project is about).
hvr commentedon Jun 20, 2018
While this ticket is about the soon to be obsolete
(old)-replsemantics; things get a lot more interesting in thenew-replparadigm, where the decision which component to load needs to take into account a multi-package situation.We have a related design issue with the semantics of which set of goals an implicit (i.e. w/o any explicit target selectors)
cabal new-buildexpands into. There we currently default to using the package that's currently in$CWDas the implicit target goal; and if there isn't any package in the current$CWD, we ask the user to disambiguate.This would naturally extend to an implicit
cabal new-repl, which should pick a default goal if and only if there's an obvious and unique(!) choice inferrable from$CWD, and if it isn't unique, ask the user to disambiguate/clarify. A related design issue concernscabal new-runwhich faces a similiar design issue (#4676). We should make sure that all these sub-design choices result in an overall consistent design of all new-* commands to reduce confusion.fgaz commentedon Jul 27, 2018
@typedrat is this fixed by #5461?
typedrat commentedon Jul 27, 2018
Nope, but only because it spaced my mind. Fixed now. 👍
dmead commentedon Aug 7, 2018
this breaks haskell-mode yes?
hvr commentedon Aug 7, 2018
@dmead can you elaborate please? are you saying that b2a4795 is causing problems for haskell-mode?