Closed DanBurton closed 9 years ago
After doing all the work of parsing/generating constraints, I discovered that this appears to be unnecessary. Perhaps this is a difference between cabal 1.18 and cabal 1.20? I'm not sure. But cat cabal.config >> cabal.sandbox.config
works exactly as expected (using both cabal 1.20.0.3 and 1.22.3.0), so essentially that's what I ended up writing. (I swear I tried this a while ago and it didn't work.) I commented out and kept the other stuff I wrote in case it is useful.
I added some logic to stk sandbox init
so that it won't keep any cabal.config
if it didn't exist prior to the command. Therefore, stk sandbox upgrade
will ultimately delete any cabal.config
it finds. We may want to revisit this behavior.
I'm going to take a little more time to test this change to stackage-sandbox before releasing it.
What's the advantage of this versus using the cabal.config file?
If the user modifies the cabal.config file (for example, by doing a git pull
when it is checked in to git) then when they perform installs in that directory, their shared LTS sandbox is at risk of installing the wrong versions of things. By copying the constraints into the cabal.sandbox.config, the sandbox is more likely to be protected.
With some tweaks to stackage-sandbox, this will also allow the user to write and manage their own custom cabal.config (e.g. via cabal freeze). As long as the constraints agree, there's no problem.
It may be difficult for the user to discover what the problem is when these constraints don't agree, since cabal is bad at reporting where constraints come from during a conflict. Cabal calls sandbox and cabal.config constraints "global", even though "sandbox" and "project" would be more appropriate labels.
I'm satisfied with the changes, so I've published them along with the stubbed library.
e.g.