Skip to content

Meta-issue: Remove need for fake-package #6977

Open

Description

@phadej

The internals of cabal-install should allow project planning without writing things to file system.

This is high-level goal, and I don't think that it could be solved with single PR. But internal changes moving us closer to it will improve state of the codebase, which is very welcome!

Activity

  1. added this to the Considered for 3.6 milestone on Jul 20, 2020
  2. fendor commented on Jul 20, 2020

    @fendor
    Collaborator

    Where is this fake-package used?
    I know of:

    • cabal scrips
  3. phadej commented on Jul 20, 2020

    @phadej
    CollaboratorAuthor

    @fendor, install, run, repl outside of project directories. About everywhere where we "solve", but don't have a local project.

  4. phadej commented on Jul 20, 2020

    @phadej
    CollaboratorAuthor

    #6885 is another (upcoming) example, where planning without relying (selectively!) on "real world" / "filesystem" inputs is desired.

  5. alexbiehl commented on Jul 20, 2020

    @alexbiehl
    Member

    We could modify the Rebuild monad. Currently it's the one that creates all the caches and triggers rebuilding in case any input changed. By providing configuration or a different interpreter we could just make it not cache things and rebuild all the time.

    Pair that with allowing an empty, implicit project and we might be golden.

  6. phadej commented on Jul 20, 2020

    @phadej
    CollaboratorAuthor

    @alexbiehl yes, that what I have tried. Yet Rebuild monad is used very little, here and there. One clear subgoal is to make project planning contained completely in Rebuild monad.

  7. alexbiehl commented on Jul 20, 2020

    @alexbiehl
    Member

    One clear subgoal is to make project planning contained completely in Rebuild monad

    Yes. Though a less invasive change might be to pass down the configuration/interpreter to the runRebuild calls. They are not too many. Maybe it even makes sense to tie the runRebuild to DistDirLayout; we are passing that around everywhere and usually the call looks like runRebuild distDirProjectRoot $ do ....

  8. phadej commented on Jul 20, 2020

    @phadej
    CollaboratorAuthor

    ... except the very first runRebuild is runRebuild "".

    I also don't understand why we work with relative paths at all. That's another yak to shave. #6667 might help.

    EDIT: I emphasize, this shouldn't be fixed in a "smallest possible diff" way, but in the "cleanest end result" way.

  9. typedrat commented on Jul 24, 2020

    @typedrat
    Collaborator

    This is very interesting. I never liked the whole fake-package chicanery, and I think I still understand how that part of Cabal works pretty well, even if I haven't been up to my arms in it recently.

    I had a few thinks about how this could be done, actually. Let me try to find my old notes!

  10. fgaz commented on Jul 30, 2020

    @fgaz
    Member

    #6999 is a specific bug caused by fake-package

  11. Mikolaj commented on Jun 22, 2021

    @Mikolaj
    Member

    It seems the slowness caused by writing to the filesystem makes cabal repl unusable to some users (e.g., haskell/cabal-userguide#1 (comment)). Therefore, given that we'd love to get rid of v1-, which they use as a substitute for cabal repl, I'd declare this set of tasks as high priority. Another solution to the slowness is cabal env, but would it not benefit from this change as well?

  12. fgaz commented on Jun 22, 2021

    @fgaz
    Member

    This change won't make cabal repl / script faster per se, it just means that instead of writing a dummy package on the file system and performing dep resolution etc on it, it should be possible to do that on the fly, without depending on a project. For it to be fast, we'd also need some way to consistently cache those build plans

  13. Mikolaj commented on Jun 22, 2021

    @Mikolaj
    Member

    Noted. Is there a ticket for the caching?

  14. 2 remaining items

  15. Mikolaj commented on Jun 22, 2021

    @Mikolaj
    Member

    Noted. There go my hopes. :)

  16. fgaz commented on Jun 22, 2021

    @fgaz
    Member

    I don't think running Cabal on a package is strictly necessary here. For repl at least, it should be enough to use an in-memory empty project, though maybe this needs a working extra-packages. Nevermind, I didn't know Cabal handled repl too

  17. gbaz commented on Jun 22, 2021

    @gbaz
    Collaborator

    I think caching of fake-pkg and etc resulting from cabal repl invocations with basically no other changes could in itself probably eliminate most of the start-up time?

  18. fendor commented on Jun 22, 2021

    @fendor
    Collaborator

    @gbaz well, yes, but I think it would be a good time to remove the fake-package as the script feature would also benefit from that.

    Additionally, if cabal repl script.hs works (which I would hope would start to work once the fake-package trick isn't used anymore), then we can even have HLS support for it, which is my personal motivation :)

  19. removed this from the Considered for 3.6 milestone on Sep 2, 2021
  20. bacchanalia commented on Feb 17, 2022

    @bacchanalia
    Collaborator

    I've been investigating this and there seem to be two separate issues.

    1. Removing the fake-project.cabal files used by global repl and scripts. This requires calling Cabal directly from cabal-install, but it's morally defensible because the build type is always Simple. A minor downside is that since we would no longer store the meta block in the fake-project.cabal file, we'd have to assume that all script changes could effect the meta block. A major upside is we'll be able to use the current directory as the project directory.
    2. Don't write cache files during project planning for non-local targets. These are written to a temp dir and never read before being deleted, so it should be straight forward to simply pass a flag to not write them.

    If I missed anything please let me know.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions