Skip to content
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

source-repository-package seems to be treated as local #5586

Closed
quasicomputational opened this issue Sep 22, 2018 · 20 comments
Closed

source-repository-package seems to be treated as local #5586

quasicomputational opened this issue Sep 22, 2018 · 20 comments

Comments

@quasicomputational
Copy link
Contributor

quasicomputational commented Sep 22, 2018

This means that --enable-tests will build the tests of those dependencies, --enable-benchmarks will build the benchmarks, new-test will (presumably) run their tests, and so on.

This was quite surprising to me, since my primary use case for source-repository-package is to swap in a broken version of a dependency with a fixed pre-release version from the VCS. But doing that means that, if the dependency's test suite is not in great condition (e.g., it doesn't even compile because I'm trying to port things to a new GHC version), I'm suddenly going to be affected by that!

The discussion in #2189 suggests that this is for implementation convenience (which is entirely reasonable), rather than a deliberate decision. Are there use cases where packages being pulled from a VCS should be local for principled reasons? I can't think of any off the top of my head, but there's a whole universe of potential weirdness out there.

Edit: Also, I suspect we could decouple the relevant aspects of 'localness': a source-repository-package could be treated as local for the purposes of recompilation checking and not going into the global store, but non-local for the purposes of 'should this package's tests/benchmarks be available for building/running?'.

@23Skidoo
Copy link
Member

/cc @dcoutts @typedrat

@hvr
Copy link
Member

hvr commented Sep 26, 2018

Fwiw, I consider having source-repository-package cached in the global store a killer feature; and I feel like in the majority of use-cases you'd want to err on caching it globally rather than not. That being said, I welcome the ability to opt-out and force it to be treated as local if the user wishes so.

Something I think I briefly discussed with Duncan in the context of the source-repo-package UI was to have a generic uniform "package" syntax where you could explicitly force/control whether a package in the build-plan is demoted to a local package or not.

@typedrat
Copy link
Collaborator

typedrat commented Oct 9, 2018

How do packages that are in an index that is referenced in a specific cabal.project but is not globally available handled? Because honestly I think internally treating the source-repository-package as a source of packages rather than adding a new local package for it makes more sense.

@RyanGlScott
Copy link
Member

What is the status of this ticket after #5708 was merged into cabal-install-2.4? I was originally redirected to this ticket after seeing #5612 (which I was directly affected by in haskell-CI/haskell-ci#186), and after upgrading to cabal-install-2.4, I can confirm that I am no longer affected by #5612. Since #5612 was closed as a duplicate of this ticket, does that mean this ticket is also fixed now?

@hvr
Copy link
Member

hvr commented Nov 26, 2018

@RyanGlScott this ticket is still relevant insofar as the source-repository-packages are still treated as if they were local packages whereas it's desirable instead to have the ability to treat them as non-local ones.

@harendra-kumar
Copy link

In a CI build --enables-tests starts building tests of a source-repository-package and sometimes the dependencies of tests even fail to build (for ghcjs in my current use case). Therefore, this issue is a must fix to enable the CI use case.

@hvr
Copy link
Member

hvr commented Jan 11, 2019

@harendra-kumar is this workaroundable by adding a package stanza matching the source-repository-package disabling the tests again? i.e. for a package foo pulled in via git,

package foo
  tests: False
  benchmarks: False

?

(if yes, maybe we can have this "hack" wired into cabal automatically, as a short-term workaround/quickfix )

@harendra-kumar
Copy link

@hvr this will work for me. I guess it makes sense to do it only if this is significantly easier/faster to do compared to the right long term fix.

RyanGlScott added a commit to RyanGlScott/ci-maintenance that referenced this issue Jan 12, 2019
Using the incredibly simple but effective trick here:
haskell/cabal#5586 (comment)

This is yet another hack needed to work around
haskell-CI/haskell-ci#184, which in turn
is needed because of
haskell/cabal#5586.
@harendra-kumar
Copy link

@hvr thanks for that workaround, works great!

@michaelpj
Copy link
Collaborator

I just hit something that I suspect is another effect of this: packages that are included as a source-repository-package will never be taken from the package-db.

Why would you want this? If you are using Nix and you are in a shell which has been prepared with your dependencies (including the source-repository-pacakges), then you want to actually use those, and not recompile them! (Why list them as source-repository-packages then? Because the cabal files are still the source of truth for the nix tooling.)

But I think this is just a consequence of source-repository-packages being treated more like local packages than "normal" dependencies.

@symbiont-sam-halliday
Copy link

Another consequence of this: if we have a freeze file (e.g. from stackage) and then a source dependency where the source version has move the version forward, then the constraint solver fails to find a solution. I think the constraint solver should ignore the constraint on the package in the case that there is an explicit source dependency (this is what stack does).

@michaelpj
Copy link
Collaborator

I just hit precisely the issue Sam mentions today.

@deepfire
Copy link

deepfire commented Apr 9, 2020

I just hit something that I suspect is another effect of this: packages that are included as a source-repository-package will never be taken from the package-db.

So, from discussion with @dcoutts, it has been further confirmed, that this shadowing is by design -- the source-repository-package is intended to designate a mandatory request to use a particular source for the particular package.

If we follow this design, then the proper solution for package DB un-shadowing would be conditionalisation of the clauses -- as per #6249

@deepfire
Copy link

deepfire commented Apr 9, 2020

Just as a matter of recording here the information:

Duncan says that to change "what is considered local for the purpose of applying project-wide flags/settings", the place to modify is
https://github.com/haskell/cabal/blob/master/cabal-install/Distribution/Client/ProjectPlanning.hs#L1926-L1936

..and so we want to drop the repositories there -- and further, that:

In fact we probably want to only include LocalUnpackedPackage

phadej added a commit to phadej/cabal that referenced this issue Jun 18, 2020
…edPackage

Also calculate hashes for all locally available tarballs.
@phadej phadej closed this as completed in 2b6cd51 Jun 20, 2020
@phadej phadej added this to the 3.4.0.0-rc1 milestone Jul 13, 2020
@jchia
Copy link

jchia commented Jul 29, 2020

With the issue closed, is a source-repository-package now supposed to be cached in the global store? I just ran cabal freeze on my project with 3.4.0.0-rc1 and saw cabal still trying to clone a github source-repository-package into dist-newstyle/src in my project directory, not somewhere in the global store. Is this expected? If so, is it correct to say that every time I build my project from scratch, cabal will still do the cloning of this github source-repository-package?

@phadej
Copy link
Collaborator

phadej commented Jul 29, 2020

The repository is cloned, but should be built only once. We decide whether it's the same via the contents, i.e. if you clone it from different fork, or get the sources somehow otherwise, it's still the same.

E.g. if the very same sdist is uploaded to the Hackage, which we get from git clone (which should be more likely if uploaders use cabal-install-3.4) then all those will be considered "the same version".

@jchia
Copy link

jchia commented Jul 30, 2020

I suppose for a Hackage package you decide whether the package is the same by the package name and version? For a source-repository-package, at least for a git package, can we decide whether the package is the same via the location and tag (commit hash)? This way, the package (source) can also stored in the global store instead of the project's dist-newstyle/src. dist-newstyle is cleared every time "cabal clean" is run and then "cabal build" will have to download the source-repository-package all over again.

@phadej
Copy link
Collaborator

phadej commented Jul 30, 2020

I suppose for a Hackage package you decide whether...

No, the contents of tarball also matter. The hash of contents (and .cabal file) are however available in 01-index, which we download from Hackage, so we don't need eagerly download sources of packages from Hackage.

@jchia
Copy link

jchia commented Jul 30, 2020

Is it a design choice to cache the source-repository-package locally instead of in the global cache or is that just the thing that happens to be easy to implement?

@fgaz
Copy link
Member

fgaz commented Jul 30, 2020

afaik it's a design choice. there should be a pr/issue somewhere with relevant discussion

infinisil added a commit to input-output-hk/ECIP-Checkpointing that referenced this issue Dec 15, 2020
For source-repository-package's, cabal tries to build them on its own, even
when all dependencies are already provided by Nix. Relevant issues:
- haskell/cabal#6049
- IntersectMBO/ouroboros-network#645
- haskell/cabal#5586 (comment)

This seems to be a problem even with a cabal that includes
haskell/cabal#6917 (see
input-output-hk/haskell.nix#720 (comment)
for how to test a cabal-install 3.4)

The only known workaround is to remove the source-repository-package
sections from cabal.project, but this should only be done for cabal when
used from a nix-shell, not from cabal without a nix-shell, and not outside
the nix-shell.

To make this work smoothly, the script `scripts/nix-setup` can be used,
which splits the source-repository-package sections into cabal.project.srcs,
which is then again included from here (to make the Nix setup still work).
Running the script again undoes it.
infinisil added a commit to input-output-hk/ECIP-Checkpointing that referenced this issue Dec 16, 2020
For source-repository-package's, cabal tries to build them on its own, even
when all dependencies are already provided by Nix. Relevant issues:
- haskell/cabal#6049
- IntersectMBO/ouroboros-network#645
- haskell/cabal#5586 (comment)

This seems to be a problem even with a cabal that includes
haskell/cabal#6917 (see
input-output-hk/haskell.nix#720 (comment)
for how to test a cabal-install 3.4)

The only known workaround is to remove the source-repository-package
sections from cabal.project, but this should only be done for cabal when
used from a nix-shell, not from cabal without a nix-shell, and not outside
the nix-shell.

To make this work smoothly, the script `scripts/nix-setup` can be used,
which splits the source-repository-package sections into cabal.project.srcs,
which is then again included from here (to make the Nix setup still work).
Running the script again undoes it.
infinisil added a commit to input-output-hk/ECIP-Checkpointing that referenced this issue Dec 16, 2020
For source-repository-package's, cabal tries to build them on its own, even
when all dependencies are already provided by Nix. Relevant issues:
- haskell/cabal#6049
- IntersectMBO/ouroboros-network#645
- haskell/cabal#5586 (comment)

This seems to be a problem even with a cabal that includes
haskell/cabal#6917 (see
input-output-hk/haskell.nix#720 (comment)
for how to test a cabal-install 3.4)

The only known workaround is to remove the source-repository-package
sections from cabal.project, but this should only be done for cabal when
used from a nix-shell, not from cabal without a nix-shell, and not outside
the nix-shell.

To make this work smoothly, the script `scripts/nix-setup` can be used,
which splits the source-repository-package sections into cabal.project.srcs,
which is then again included from here (to make the Nix setup still work).
Running the script again undoes it.
infinisil added a commit to input-output-hk/ECIP-Checkpointing that referenced this issue Dec 16, 2020
For source-repository-package's, cabal tries to build them on its own, even
when all dependencies are already provided by Nix. Relevant issues:
- haskell/cabal#6049
- IntersectMBO/ouroboros-network#645
- haskell/cabal#5586 (comment)

This seems to be a problem even with a cabal that includes
haskell/cabal#6917 (see
input-output-hk/haskell.nix#720 (comment)
for how to test a cabal-install 3.4)

The only known workaround is to remove the source-repository-package
sections from cabal.project, but this should only be done for cabal when
used from a nix-shell, not from cabal without a nix-shell, and not outside
the nix-shell.

To make this work smoothly, the script `scripts/nix-setup` can be used,
which splits the source-repository-package sections into cabal.project.srcs,
which is then again included from here (to make the Nix setup still work).
Running the script again undoes it.
puffnfresh added a commit to puffnfresh/nix-tools that referenced this issue Jul 7, 2021
hamishmack pushed a commit to input-output-hk/nix-tools that referenced this issue Jul 10, 2021
andreabedini pushed a commit to andreabedini/haskell.nix that referenced this issue Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests