purescript / spago

🍝 PureScript package manager and build tool
BSD 3-Clause "New" or "Revised" License
793 stars 132 forks source link

Spago does not use `packages` key to get package set values #821

Closed JordanMartinez closed 1 year ago

JordanMartinez commented 3 years ago

While reviewing this PR, https://github.com/purescript/registry/pull/234#discussion_r711108420, I discovered that modifying the spago.dhall file's packages' key's content isn't reflected in commands like spago ls packages.

I'm not sure whether this is a bug or if it's intentional.

f-f commented 3 years ago

This doesn't sound right - are you able to put together a small repro that I can look at?

JordanMartinez commented 3 years ago

Sure.


$ mkdir spagoPackagesBug
$ cd spagoPackagesBug
$ spago init
-- edit the spago.dhall file
-- so that the packages key shows
-- ` packages = ./packages with metadata.version = "v0.13.0"`
$ cat << EOF > spago.dhall
{ name = "my-project"
, dependencies = [ "console", "effect", "prelude", "psci-support" ]
, packages = ./packages.dhall with metadata.version = "v0.13.0"
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
}
EOF
$ spago ls packages | grep 'metadata'
metadata                         v0.14.3   Remote "https://github.com/spacchetti/purescript-metadata.git"
f-f commented 3 years ago

Thank you! This is a bug - and it happens because we try to be smart about reading files: for the ls packages command we don't strictly need the spago.dhall, so in order to work in places where we only have a packages.dhall (such as for example in the root of a monorepo) we try to read that first. This is the code: https://github.com/purescript/spago/blob/7728ce42a1c66968cce7a72dbb6ab05ea0904d9f/src/Spago/RunEnv.hs#L194-L203

f-f commented 1 year ago

The new Spago fixes this, closing