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

Autoinstall missing packages #1211

Open
klntsky opened this issue Apr 8, 2024 · 5 comments
Open

Autoinstall missing packages #1211

klntsky opened this issue Apr 8, 2024 · 5 comments

Comments

@klntsky
Copy link
Collaborator

klntsky commented Apr 8, 2024

Instead of suggesting the user to copy-paste the command from the terminal, like here:

[error] Some of your project files import modules from packages that are not in the direct dependencies of your project.
To fix this error add the following packages to the list of dependencies in your config:
- aff
- datetime
- foldable-traversable
- maybe
- newtype
- numbers
- ordered-collections
- transformers
You may add these dependencies by running the following command:
spago install aff datetime foldable-traversable maybe newtype numbers ordered-collections transformers

a flag could be added, e.g. spago install --missing to install these automatically

@f-f
Copy link
Member

f-f commented Apr 12, 2024

I considered this before (I would have called the flag --pedantic-packages-autofix) but ultimately decided to not go for it - and the main reason is that in a monorepo setting with many packages you would get different spago commands to copypaste, and it could be that you would then decide to enable the pedantic check for some packages but not for others. Then the autofix would need to be tailored to a specific package. Then there's the issue of tests: you would get a separate command to fix dependencies in your test suites. Again, it could be that instead of fixing it you would want to disable the pedantic check for those.

So in the end I am not sure it would be actually more convenient than having the commands printed there?

@CGenie
Copy link

CGenie commented Apr 16, 2024

BTW, could you explain a bit more: it seems that spago build sometimes builds my project without complaint and then I try to publish, it warns about missing deps.

E.g. https://github.com/garganscript/purescript-sequences/blob/spago-next/spago.yaml

I added only prelude as a dependency and it builds just fine. However, there's lots of other deps such as arrays etc but it doesn't complain about them missing. Also, spago ls deps returns prelude only. I can run spago repl and test out the code, and in .spago/p I can see the arrays module being installed.

So I'm a bit confused what to put in dependencies now.

@f-f
Copy link
Member

f-f commented Apr 19, 2024

@CGenie the publishing checks include verifying that the dependencies of your package are accurate, so that:

  • the list of dependencies does not contain packages that are not being imported by your modules
  • the modules in your package do not import modules from packages that are not declared in the dependencies

These are both situations that you would not easily detect when just writing code. They are also not critical, in the sense that during normal development you might only care about your package compiling, rather than the project manifest being 100% accurate.

It's possible to have Spago check this for you on a one-off basis, by enabling the --pedantic-packages flag when building, or on a regular basis by setting pedanticPackages: true in the config file (look it up in the docs).

The default situation is that Spago does not check until it's required, which is at the time of publishing your package - this is what just happened to you

@f-f
Copy link
Member

f-f commented Apr 19, 2024

Btw, the reason why you can have only prelude in the list of dependencies and have all the other packages available (such as array, etc) is that you have things like quickcheck in the dependencies list of your test package. That brings in all those packages and makes them "available" for your build to use.

Running spago ls deps --transitive will list out all the packages that are brought in as dependencies of your dependencies.
And spago graph packages will give you a graph (in various formats) based on the dependency relations.

@CGenie
Copy link

CGenie commented Apr 19, 2024

Thank you!

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

3 participants