-
Notifications
You must be signed in to change notification settings - Fork 700
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
Cannot install a profiled library with cabal install --lib -p pkgname
#7832
Comments
looks like a dup of #5982 and #7297 (and related to #7236) Ideally this will all be resolved as part of revamping cabal v2-install functionality entirely as per #6481 (also note that this describes in the discussion that you can just delete the world file from your cabal directory if it was somehow created and is corrupt) |
I understood #5982, #7297, and #7236 as being about executables, not libraries -- so I did not look closely at them (though I did find them in my searches before posting). Glad to see that there appears to be action at #6481 -- I'm eager for that feature. For the record, the world file seems just fine -- I don't see how that could be the issue here. It says If this ticket really is a dup of others, please close. I suppose the workaround is to create a |
Just the cabal.project should be enough iirc |
That surprises me. I can have a |
It'd be a project with no local packages |
They were started about executables but the underlying issue is the same in all cases as far as we know from our sleuthing. Vis a vis world files, I'm just suggesting that if v1-anything is failing due to a world file error, its safe to delete the file, its vestigal and the entire half-implemented-never-working feature is removed in the next cabal release. |
@fgaz I tried your suggestion about I have
( cabal-install complains:
This is a strange message: it's either a logic bug (because I definitely do have I also tried to rename
Any thoughts on this or how to get profiling libs without |
How much time is really "wasted" if you'd rather write a proper I.e. what can be done better or differently so people would just make ad-hoc packages&projects, instead of trying to use |
To answer @ulysses4ever question, you can work around that error by putting those packages (or even just a random package, like
I do somewhat agree with @phadej though |
Hmm, you're right... I think it should work so imo it's a bug. I've used this capability plenty of times with source-repository-package, and in that case it does work. |
I think this is a great question. Perhaps you're right that some of us (myself definitely included) are simply pre-conditioned to not want to make a project file. Here are some things that make writing a .cabal file annoying for me:
Actually, those bullets aren't an answer to your question of "what would have to be different?". I suppose, for me, one way to move forward would be to allow some In short: I, personally, am willing to maintain some kind of global |
That is incorrect. Minimal cabal-version: 3.4
name: foo
version: 0
library
build-depends: base, text, containers, deepseq, another-dependency
exposed-modules: Foo (Thing about You should write the rest of the details if you want to publish the package, as you probably should to clean up the Haskell code as well.
Add {-# OPTIONS_GHC -ddump-tc-trace -dsuppress-var-kinds -fprint-explicit-kinds #-} to the top your module. |
The workflows you suggest still require me, for every directory I'm working in, to maintain separate .cabal files. When I add a dependency to each one, I'm sure some time will be spent building the libraries. This would not work in a teaching setting. And, in my GHC work, I frequently call GHC with different flags serially, in order to get different outputs, so editing the source file would be annoying. Maybe that's just me, and I'm too small a use case. You asked what I would need in order to be more satisfied in my use of cabal. I answered, and you offered workarounds. I've been aware of workarounds to my problems for years, but they've never been satisfying. They still aren't. |
What you mean by "maintain"? I had impression that you want to try something out, and then "forget" about that code. But if you expect to come back to these experiments days, weeks or months later, then writing
Maybe, but somewhat unlikely: that's the "magic" of |
Two points here. I have been a happy user of (although mouthful) Second, to your question @phadej, I'd ask another question: do you see it reasonable to ask Some other random issues I have with |
My suggestion for this has always been, let there be a This hypothetical option would strike a great balance between the convenience of cabal v1 and the composability of cabal v2. |
Calculating a maximal set of compiled packages is worst case exponential I think (I mean, solving alone is np-complete, but this is arguably exp-worst or so on top of that) |
by the way, |
Could be, but I can't see what's wrong with this algorithm sketch which seems to be polynomial:
It looks polynomial as I have presented it. Perhaps I have missed an important ingredient. Practically speaking, I think that choosing P to be the most recently installed package not in S would be a good heuristic. |
Perhaps "maximal" is ambiguous. I don't mean a consistent set of packages of largest size. I mean a consistent set of packages to which no other package can be consistently added. I agree the former has an exponential smell to it. |
@tomjaguarpaw while it seems polynomial to me too, it does not guarantee that you end up with a substantial portion of Hackage (or even Stackage) because of 4.a ("if ... discard PD"). Maybe with a cleverly picked seed value of S ("roots" of the search), instead of {}, this may yield reasonable results (or maybe not: one'd have to try). I'm sympathetic to this idea. In fact, several month ago @emilypi mentioned somewhere that cabal.freeze files could effectively model stack resolvers and the only thing that is missed is infrastructure to easily get these files on the user side: someone have to make effort 1) converting stack snapshots into cabal.freeze files; 2) publish them somewhere; 3) (perhaps hardest) figure out a seamless way to deliver them to the user (ideally, a cabal-command, I think). That's predicated on willingness to rely on |
Those are already public, though hidden: commercialhaskell/stackage-server#232 |
My guess is that the algorithm, combined with the heuristic of always choosing as P the most recently installed package not in S, ends up with a superset of the packages that would be available if the user had instead been using the v1 commands (perhaps exactly the same set of packages). Since @rae seems implicitly to be asking for v1-style behaviour this algorithm seems like a good way of satisfying him whilst staying within the more principled v2 world. |
I worry that as a heuristic this may be usually ok, but it will at times be utterly confusing. Suppose I have a setup I'm fairly happy with, then I go off and try out some old piece of code that still compiles, but has a lot of strict upper bounds, which in turn pulls in other older stuff, etc. Now, all of a sudden the "most recent package" has a generally far less desirable universe, and the workflow that was nice for me yesterday when just playing around all of a sudden has broken, because the heuristic now is picking out a very different set of packages. As this discussion has gone pretty astray, I should underline, we do have on our roadmap fixing the actual issue highlighted here, and more generally reworking the ergonomics and UI of However, experience has repeatedly shown that "do what I mean" algos in package management lead to frustrated and confused users, and while things should be as easy as possible, they should also be no easier than that, and finding that balance is not going to be simple. |
Great -- glad to hear it. Thank you.
I agree here, and have not thought about the specific of the algorithms above. But, there is an algorithm that is known to (mostly) work: what v1 did. That is, the universe expands only by user request, when that user asks to add a new package to their universe. At that point, cabal selects the most recent release of that package (or whatever version the user asked for). Then, cabal uses the same algorithm it usually uses to decide its dependencies. This worked for the lifetime of v1. But it only mostly worked, because of cabal-hell: that's why v2 exists! So there would be a potential pitfall in that users try to build an inconsistent universe, or they build a consistent universe that doesn't serve their actual needs. I'm not sure those pitfalls are avoidable... but maybe they could be mitigated with |
Well there had been really interesting discussions and thoughts here, but the original report is essentially #7297, so maybe we should rename it or close it as duplicate |
This doesn't strike me as exactly #7297: this bug is about |
cabal install --lib -p pkgname
@gbaz , you wrote
That is great! Do you have a time or an eta for the preceding? Thanks! |
The underlying issue is discussed in #7297 which has been in the list of desired foxes for a few releases, but it needs someone to want to work on it. Essentially |
This should also be fixed by #9697. |
The target of `cabal install` is not considered to be a local package, which means local configuration (e.g. in cabal.project, or flags like --enable-profiling) does not apply to it. In 76670eb, we changed the behaviour to applying the local flags to cabal install targets, but it used the literal target string as a package name to which the flags were additionally applied. However, `cabal install` targets are NOT necessarily package names, so, e.g., if we did `cabal install exe:mycomp`, the local flags would not apply since "exe:mycomp" is not a recognized /package/. The solution is to parse the target selectors first, and apply the local flags to the package of the resolved targets. Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
The target of `cabal install` is not considered to be a local package, which means local configuration (e.g. in cabal.project, or flags like --enable-profiling) does not apply to it. In 76670eb, we changed the behaviour to applying the local flags to cabal install targets, but it used the literal target string as a package name to which the flags were additionally applied. However, `cabal install` targets are NOT necessarily package names, so, e.g., if we did `cabal install exe:mycomp`, the local flags would not apply since "exe:mycomp" is not a recognized /package/. The solution is to parse the target selectors first, and apply the local flags to the package of the resolved targets. Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
The target of `cabal install` is not considered to be a local package, which means local configuration (e.g. in cabal.project, or flags like --enable-profiling) does not apply to it. In 76670eb, we changed the behaviour to applying the local flags to cabal install targets, but it used the literal target string as a package name to which the flags were additionally applied. However, `cabal install` targets are NOT necessarily package names, so, e.g., if we did `cabal install exe:mycomp`, the local flags would not apply since "exe:mycomp" is not a recognized /package/. The solution is to parse the target selectors first, and apply the local flags to the package of the resolved targets. Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
The target of `cabal install` is not considered to be a local package, which means local configuration (e.g. in cabal.project, or flags like --enable-profiling) does not apply to it. In 76670eb, we changed the behaviour to applying the local flags to cabal install targets, but it used the literal target string as a package name to which the flags were additionally applied. However, `cabal install` targets are NOT necessarily package names, so, e.g., if we did `cabal install exe:mycomp`, the local flags would not apply since "exe:mycomp" is not a recognized /package/. The solution is to parse the target selectors first, and apply the local flags to the package of the resolved targets. Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
The target of `cabal install` is not considered to be a local package, which means local configuration (e.g. in cabal.project, or flags like --enable-profiling) does not apply to it. In 76670eb, we changed the behaviour to applying the local flags to cabal install targets, but it used the literal target string as a package name to which the flags were additionally applied. However, `cabal install` targets are NOT necessarily package names, so, e.g., if we did `cabal install exe:mycomp`, the local flags would not apply since "exe:mycomp" is not a recognized /package/. The solution is to parse the target selectors first, and apply the local flags to the package of the resolved targets. Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
The target of `cabal install` is not considered to be a local package, which means local configuration (e.g. in cabal.project, or flags like --enable-profiling) does not apply to it. In 76670eb, we changed the behaviour to applying the local flags to cabal install targets, but it used the literal target string as a package name to which the flags were additionally applied. However, `cabal install` targets are NOT necessarily package names, so, e.g., if we did `cabal install exe:mycomp`, the local flags would not apply since "exe:mycomp" is not a recognized /package/. The solution is to parse the target selectors first, and apply the local flags to the package of the resolved targets. Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
Fixed by #9697 |
The target of `cabal install` is not considered to be a local package, which means local configuration (e.g. in cabal.project, or flags like --enable-profiling) does not apply to it. In 76670eb, we changed the behaviour to applying the local flags to cabal install targets, but it used the literal target string as a package name to which the flags were additionally applied. However, `cabal install` targets are NOT necessarily package names, so, e.g., if we did `cabal install exe:mycomp`, the local flags would not apply since "exe:mycomp" is not a recognized /package/. The solution is to parse the target selectors first, and apply the local flags to the package of the resolved targets. Fixes haskell#7297, haskell#8909, the install part of haskell#7236, haskell#8529, haskell#7832
Use case
I would like to experiment with performance characteristics of a few library functions. I am not building software to ship. I am just trying to learn more about Haskell. So I'd like to be able, say, to build an executable that depends on a few packages without needing to edit a .cabal file every time I change the set of dependencies. (Remember: the goal is quick experimentation!) A key requirement is that I need profiled libraries. The first one I wish to use is
random
. Read on to see what happens:Describe the bug
I say
cabal install --lib -p random
. Cabal responds withResolving dependencies... Up to date
. Sounds encouraging. I can confirm thatghc Experiment.hs
(which hasimport System.Random
) works. But I want to sayghc Experiment.hs -prof
. That does not work, with GHC saying I need profiled libraries. Note that I asked for profiled libraries with-p
, above. I think: maybe my environment file has a stale entry. So I edit my env file to delete the line withrndm
. I thencabal install --lib -p random
again. The env file re-grows itsrndm
line... but the library still isn't profiled. I'm now pretty stuck.Being stuck, but still eager to make progress, I try
cabal v1-install -p random
, remembering that such a command used to work brilliantly. After doing some building, I now getSo that didn't work. I'm now completely stuck. I decide to do something other than learn more about Haskell for now.
To Reproduce
Included in the narrative above.
Expected behavior
I expected the first
cabal install --lib -p random
to update my env file with the correct entry to be able to do a profiled build depending onSystem.Random
.System information
Cabal-3.6.2.0
,cabal-install-3.6.2.0
,ghc-8.10.7
The text was updated successfully, but these errors were encountered: