Skip to content

No way of specifying a remote-repo in a sandbox #1884

Closed

Description

@snoyberg

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?

Activity

  1. bergmark commented on May 21, 2014

    @bergmark
    Contributor

    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.

  2. self-assigned this
    on May 21, 2014
  3. AshleyYakeley commented on Jun 5, 2014

    @AshleyYakeley
    Member

    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.

  4. ygale commented on Jun 5, 2014

    @ygale
    Contributor

    A few questions:

    1. 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?
    2. 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.
    3. 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.
  5. AshleyYakeley commented on Jun 5, 2014

    @AshleyYakeley
    Member
    1. 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.
    2. 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.
    3. 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.
  6. Profpatsch commented on Jul 20, 2014

    @Profpatsch

    This should be fixed to make sandboxes work as intended. As it is now, they are a somewhat leaky concept.

  7. luite commented on Aug 20, 2014

    @luite
    Member

    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?

  8. ygale commented on Aug 20, 2014

    @ygale
    Contributor

    @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.

  9. 23Skidoo commented on Aug 20, 2014

    @23Skidoo
    Member

    @ygale Once #2041 is done, we can add a comment to the auto-generated cabal.config file.

  10. dcoutts commented on Aug 23, 2014

    @dcoutts
    Contributor

    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.

  11. 23Skidoo commented on Aug 23, 2014

    @23Skidoo
    Member

    @dcoutts

    An "include" statement feels a bit coarse-grained. I think that this mechanism should work on per-option basis.

    For example:

    remote-repo: foo  -- inherit
    remote-repo: !foo -- override
    
  12. luite commented on Aug 23, 2014

    @luite
    Member

    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:

    remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive
    remote-repo: <unset>
    remote-repo: hdiff.luite.com:http://hdiff.luite.com/packages/archive
    

    where a <> unset = mempty

    your syntax could be usable as a shortcut for unset followed by a new value.

  13. gilligan commented on Sep 11, 2014

    @gilligan

    Any progress on this ?

  14. luite commented on Sep 11, 2014

    @luite
    Member

    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.

  15. 14 remaining items

  16. snoyberg commented on Nov 14, 2014

    @snoyberg
    CollaboratorAuthor

    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.

  17. luite commented on Nov 14, 2014

    @luite
    Member

    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"?

  18. snoyberg commented on Nov 17, 2014

    @snoyberg
    CollaboratorAuthor

    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.

  19. added 2 commits that reference this issue on Nov 17, 2014
    5fcf3d9
    6f74da0
  20. luite commented on Nov 17, 2014

    @luite
    Member

    Great, thanks for doing the work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions