Internal libraries does not work if there's no main library #3787
Comments
I am very surprised that this would be valid. What's the point of a sublibrary if there are no executables or libraries depending on it? Does cabal-install build it? Perhaps change the title of your issue to "internal libraries don't work if there's no main library" |
@mgsloan If I add the following executable section, I get the same error.
|
@mgsloan To answer your other question, |
Gotcha. Not sure when I'll have time to fix this. Seems like it should be a matter of finding that error message in the code and making it accept that condition. Might be tricky though, remains to be seen. Want to have a try at fixing it? PRs are appreciated! |
Just a message to anyone running into this problem. This happens when you give your library a name. If your package only has one library, you should not give it a name, and it will automatically get the name from the cabal file. Giving it a name apparently makes it 'internal', which is something stack doesn't support yet apparently :) |
Yeah, I think it's just a matter of removing the assumption that you'll have a main library if there are internal libraries. Not sure how to resolve this, it is not a usecase I currently care about. I'm actually not sure why internal libraries are useful. It's for backpack, right? |
@mgsloan my usecase is as follows: my package is an executable and should not export a library but I need my code to be a hidden library for my tests. I think this should be a common case. @RyanGlScott I believe internal libraries without a main library worked for you in Stack, right? do you remember which Stack version did you use? |
I only tested with |
I see, so apparently Stack does not support this scenario yet. |
Currently it doesn't. I encourage you to dig into the code and make it happen, though! I don't think it would be a substantial change. |
This is the scenario I need to work as well. I need an internal library to share between the executable and the test-suite, but I don't want to export the internal "guts". |
I have a fix for this too, will send a PR in the coming days once I write the integration tests. |
General summary/comments (optional)
Internal libraries does not work.
Steps to reproduce
Expected
it to build fine.
Actual
Stack version
The text was updated successfully, but these errors were encountered: