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
No way of specifying a remote-repo in a sandbox #1884
I initially asked this as a Stack Overflow questions. Apologies if this is not in fact a bug, but I can't seem to find any way to accomplish what I'm trying to do.
I would like to work on a project in a cabal sandbox. But instead of using the same remote-repo as my non-sandboxed code (i.e., Hackage), I'd like to point to a different remote repo. I tried creating a cabal.config file in the project directory with a remote-repo line, but it seemed to have no effect; running cabal update after that indicated that Hackage was being downloaded, but not my custom repo.
Is this use case supported, and if so, how do I achieve it?
An issue I ran across might have the same cause: if you generate a cabal.config with cabal freeze you cannot use it with --config-file. Here you might expect that it would combine the user level config and the specified one.
cabal update looks only at the global .cabal/config. cabal install looks at both the global .cabal/config and the sandbox cabal.config and uses all the remote-repo lines.
Not sure what the best thing is, but update should at least work the same ways as install.
If one or more remote-repo is specified locally, does that imply that the ones in the global config should not be used in this sandbox? Do we also want to support the use case of adding an additional local remote-repo to the global ones, and if so, how would we distinguish the two semantics?
When a remote-repo is specified locally, where is its package index stored? In my opinion, locally would make the most sense; if two different sandboxes happen to use the same local remote-repo, you don't want an update to affect the way the solver will work in the other.
Depending on the answers to the previous questions, how do we want cabal update to work? Do we want options to allow updating only global repos, only local repos, or both? What should the default be? If indexes remain a global-only concept as they are now, then I would not want the default to be to update a local remote-repo, because that could impact other sandboxes.
Currently most settings (e.g, with-compiler) essentially have type String, and lines in files can only modify the setting by replacing it or not (i.e., const s or id). But the remote-repo setting has type [String]. I propose we keep the notion that a file can only modify the setting by replacing it or not. So, if one or more remote-repo is specified locally, that counts as replacing the setting and the global remote-repo is not used. The only wrinkle is that it is impossible to set remote-repo to the empty list, but I don't think that matters.
The package index location is controlled by remote-repo-cache, which should be independent of remote-repo. It can be set in the sandbox's cabal.config (I hope). As to where it defaults to, my preference is the sandbox.
cabal update should behave the same way as the other commands: it should calculate remote-repo and remote-repo-cache, and update those repos in that location.
I have implemented the behaviour for remote-repo as described by @AshleyYakeley in the ghcjs branch of the ghcjs fork of Cabal. I'll check if remote-repo-cache is handled too.
Since there appears to be interest in fixing this, I'll split out the patch within a few days and submit it before the rest of the GHCJS patch. Does anyone object to the behaviour where remote-repo in a sandbox competely replaces any existing remote-repo setting?
In my opinion, the only problem with that behavior is that it might be very surprising and perplexing to some people, so it needs to be documented. In fact, from the discussion above, the opposite behavior might be just as surprising to some other people, so it's even more important for whatever we implement to be documented.
The trouble is, I'm not sure where the right place is to put that documentation so that people who need to know about this will have some reasonable chance of seeing it.
Whether things in the local config overrides the global or not is currently rather unclear (to users I mean). What I'd like to see is that we introduce a mechanism to make this fully explicit, and then there's no more confusion. We should have an "include" or similar, and then by default have local config files include the per-user ~/.cabal/config one (or not, depending on the desired behaviour). Similarly, the sandbox config vs the local config, we should not implicitly include both, but have one very explicitly include the other.
If we need a mechanism for selective including then fine.
I like the idea of include. Inserting the contents of a config file would have the same effect as an include directive at the same location, which makes things nice and clear.
Selective imports sound a bit tricky though. Having a way to reset a field to a default value might be better:
I think most people were at ICFP last week, which could've been the reason for the low activity. I'm back now, and unless anyone has objections or steps up I'll try to implement the approach from my last message next weekend.
I've implemented both the cabal update fix and @23Skidoo's approach (3) above, namely, override fields. This is now available as pull request: #2221. Please review.
The patch that I mentioned required more changes in the data types than I was comfortable with, since it supported an unset value for every flag. @snoyberg's patch is a lot smaller than that, since it makes remote-repo a special case, and override part of the RemoteRepo data type. I have to admit that I'm not too keen on this, but it could be a pragmatic fix to address an immediate need if we can extend this override syntax later to all fields and implement it in a more principled way.
I personally still like the idea of explicitly including things best, even when keeping it simple (no partial imports), since it's easy to explain and understand and immediately works for all fields. Unfortunately I didn't complete the implementation since I ran out of time, and many other things here have been taking more time than I hoped (like making GHCJS work with GHC HEAD again) recently.
I'll dig up what i got for my include implementation this weekend, I'm don't remember how close to ready it is or what it still takes to finish it, but I guess letting it sit on my hard drive only delays a solution.
Somewhat off-topic: Since GHC 7.10 is nearing, I feel that there must be more problems similar to this one that we really want fixed before the branch for 7.10 is cut, but are in need of some attention to get unstuck. I can spend some time on this, Sunday-Wednesday for example, be online on IRC (google talk or other is ok too) and try to help others navigating the source and discuss solutions. Should we do something like this, agree on a bunch of higher priority tickets and do a distributed "mini-hackathon"?
Activity
bergmark commentedon May 21, 2014
An issue I ran across might have the same cause: if you generate a cabal.config with
cabal freezeyou cannot use it with--config-file. Here you might expect that it would combine the user level config and the specified one.AshleyYakeley commentedon Jun 5, 2014
cabal updatelooks only at the global.cabal/config.cabal installlooks at both the global.cabal/configand the sandboxcabal.configand uses all theremote-repolines.Not sure what the best thing is, but
updateshould at least work the same ways asinstall.ygale commentedon Jun 5, 2014
A few questions:
remote-repois specified locally, does that imply that the ones in the global config should not be used in this sandbox? Do we also want to support the use case of adding an additional localremote-repoto the global ones, and if so, how would we distinguish the two semantics?remote-repois specified locally, where is its package index stored? In my opinion, locally would make the most sense; if two different sandboxes happen to use the same localremote-repo, you don't want anupdateto affect the way the solver will work in the other.cabal updateto work? Do we want options to allow updating only global repos, only local repos, or both? What should the default be? If indexes remain a global-only concept as they are now, then I would not want the default to be to update a localremote-repo, because that could impact other sandboxes.AshleyYakeley commentedon Jun 5, 2014
with-compiler) essentially have typeString, and lines in files can only modify the setting by replacing it or not (i.e.,const sorid). But theremote-reposetting has type[String]. I propose we keep the notion that a file can only modify the setting by replacing it or not. So, if one or moreremote-repois specified locally, that counts as replacing the setting and the globalremote-repois not used. The only wrinkle is that it is impossible to setremote-repoto the empty list, but I don't think that matters.remote-repo-cache, which should be independent ofremote-repo. It can be set in the sandbox's cabal.config (I hope). As to where it defaults to, my preference is the sandbox.cabal updateshould behave the same way as the other commands: it should calculateremote-repoandremote-repo-cache, and update those repos in that location.Profpatsch commentedon Jul 20, 2014
This should be fixed to make sandboxes work as intended. As it is now, they are a somewhat leaky concept.
luite commentedon Aug 20, 2014
I have implemented the behaviour for
remote-repoas described by @AshleyYakeley in the ghcjs branch of the ghcjs fork of Cabal. I'll check ifremote-repo-cacheis handled too.Since there appears to be interest in fixing this, I'll split out the patch within a few days and submit it before the rest of the GHCJS patch. Does anyone object to the behaviour where
remote-repoin a sandbox competely replaces any existingremote-reposetting?ygale commentedon Aug 20, 2014
@luite Thanks for all that!
In my opinion, the only problem with that behavior is that it might be very surprising and perplexing to some people, so it needs to be documented. In fact, from the discussion above, the opposite behavior might be just as surprising to some other people, so it's even more important for whatever we implement to be documented.
The trouble is, I'm not sure where the right place is to put that documentation so that people who need to know about this will have some reasonable chance of seeing it.
23Skidoo commentedon Aug 20, 2014
@ygale Once #2041 is done, we can add a comment to the auto-generated
cabal.configfile.dcoutts commentedon Aug 23, 2014
Whether things in the local config overrides the global or not is currently rather unclear (to users I mean). What I'd like to see is that we introduce a mechanism to make this fully explicit, and then there's no more confusion. We should have an "include" or similar, and then by default have local config files include the per-user ~/.cabal/config one (or not, depending on the desired behaviour). Similarly, the sandbox config vs the local config, we should not implicitly include both, but have one very explicitly include the other.
If we need a mechanism for selective including then fine.
23Skidoo commentedon Aug 23, 2014
@dcoutts
An "include" statement feels a bit coarse-grained. I think that this mechanism should work on per-option basis.
For example:
luite commentedon Aug 23, 2014
I like the idea of include. Inserting the contents of a config file would have the same effect as an include directive at the same location, which makes things nice and clear.
Selective imports sound a bit tricky though. Having a way to reset a field to a default value might be better:
where
a <> unset = memptyyour syntax could be usable as a shortcut for unset followed by a new value.
gilligan commentedon Sep 11, 2014
Any progress on this ?
luite commentedon Sep 11, 2014
I think most people were at ICFP last week, which could've been the reason for the low activity. I'm back now, and unless anyone has objections or steps up I'll try to implement the approach from my last message next weekend.
14 remaining items
cabal update: use sandbox config file haskell#1884
Allow remote repos to override previous repos haskell#1884
cabal update: use sandbox config file haskell#1884
Allow remote repos to override previous repos haskell#1884
snoyberg commentedon Nov 14, 2014
I've implemented both the
cabal updatefix and @23Skidoo's approach (3) above, namely, override fields. This is now available as pull request: #2221. Please review.luite commentedon Nov 14, 2014
The patch that I mentioned required more changes in the data types than I was comfortable with, since it supported an
unsetvalue for every flag. @snoyberg's patch is a lot smaller than that, since it makesremote-repoa special case, and override part of theRemoteRepodata type. I have to admit that I'm not too keen on this, but it could be a pragmatic fix to address an immediate need if we can extend this override syntax later to all fields and implement it in a more principled way.I personally still like the idea of explicitly including things best, even when keeping it simple (no partial imports), since it's easy to explain and understand and immediately works for all fields. Unfortunately I didn't complete the implementation since I ran out of time, and many other things here have been taking more time than I hoped (like making GHCJS work with GHC HEAD again) recently.
I'll dig up what i got for my include implementation this weekend, I'm don't remember how close to ready it is or what it still takes to finish it, but I guess letting it sit on my hard drive only delays a solution.
Somewhat off-topic: Since GHC 7.10 is nearing, I feel that there must be more problems similar to this one that we really want fixed before the branch for 7.10 is cut, but are in need of some attention to get unstuck. I can spend some time on this, Sunday-Wednesday for example, be online on IRC (google talk or other is ok too) and try to help others navigating the source and discuss solutions. Should we do something like this, agree on a bunch of higher priority tickets and do a distributed "mini-hackathon"?
cabal update: use sandbox config file haskell#1884
SavedConfig Monoid instance: make list fields work like Flags.
SavedConfig Monoid instance: make list fields work like Flags.
SavedConfig Monoid instance: make list fields work like Flags.
snoyberg commentedon Nov 17, 2014
Note that I have backported @23Skidoo's patch to cabal 1.20 and am now using it on my local system with Stackage, and it appears to work just fine.
SavedConfig Monoid instance: make list fields work like Flags.
SavedConfig Monoid instance: make list fields work like Flags.
luite commentedon Nov 17, 2014
Great, thanks for doing the work!