spago icon indicating copy to clipboard operation
spago copied to clipboard

Build new package when installed

Open wclr opened this issue 4 years ago • 10 comments

spago install package-name

Doesn't seem to build a newly downloaded package.

So have to do after:

spago build [--deps-only]

Though it is not very convenient as it rebuilds all the sources, at least what I see.

wclr avatar Mar 22 '21 08:03 wclr

I agree that building a package after installing it could be convenient, but what we always meant by "install" in Spago is "download locally". For building packages we only used the "build" verb.

I wonder what's the usecase for this?

About rebuilding all sources: Spago does not decide which sources need to be built, we pass all the globs to the compiler and the compiler decides what to build.

f-f avatar Mar 22 '21 11:03 f-f

Ok, I checked now that without vscode running in the same directory after installing a new package and running spago build it builds only new dependencies.

So is probably the known issue with vscode watching you were talking about. I believe it refers then to https://github.com/purescript/purescript repo? But I don't see the issue there. And I just wonder how does it really mess with vscode watcher, any ideas for this?

wclr avatar Mar 22 '21 16:03 wclr

I cannot find the relevant issue in the purescript repo unfortunately. I can only say that so far the recommended workflow is spago install package-name and spago build --deps-only. I'm open to change/improve this, but we'd need to figure out a better UX (if any) first

f-f avatar Mar 23 '21 14:03 f-f

Well the UX good would be spago install package-name --build or if decide that it should build by default, then spago install package-name --no-build. And spago could send to purs.bin only globs related to newly installed packages (I'm more with the later option).

But I'm more concerned about this with total rebuilding bug, I will look into what really causes it, will open an issue PS repo.

wclr avatar Mar 23 '21 16:03 wclr

I'm interested in working on this; I'm just wondering what UX we're going with. Will it be @wclr's --build suggestion? I don't mind waiting until there's a consensus.

triallax avatar Mar 31 '21 16:03 triallax

On the one hand, things should be explicit, so the --build option would be preferred.

But from the use case perspective, when a user installs a package in 99% percent of cases one would want it to be compiled and available to the code, this speaks for --no-build option which is used when a use case is specific.

Though probably it is better to start with --build option, as this is just a non-breaking anything addition, and could be changed in future easily if decided.

wclr avatar Apr 03 '21 05:04 wclr

We are generally fine with breaking changes, that's not really the issue here. The reason why I have doubts about this is that we'd change the general meaning of the CLI commands. So far it has been that

  • install downloads packages, eventually adding them to your config
  • build invokes the compiler, eventually calling install if the packages are missing

You are proposing that we change it to:

  • install downloads and builds packages, eventually adding them to your config
  • build invokes the compiler, eventually calling install if the packages are missing

Do you see the circular dependency? How should we untangle it?

f-f avatar Apr 03 '21 18:04 f-f

Maybe we should separate spago install (renaming it to spago fetch) from spago install package-name. In this way it would make sense that fetch does a different thing than install, which would also build the packages when adding them to the config. We'd have to rename a few flags along the way too, e.g. --no-install could become --no-fetch. How does this sound?

f-f avatar Apr 03 '21 18:04 f-f

Maybe we should separate spago install (renaming it to spago fetch)

What are the real use cases for using fetch vs installing and building the package?

I can think of one: to check if the package exists, download and check if it would conflict with the codebase, but that would require kind of build, but at least it is the real and useful use case.

wclr avatar Apr 04 '21 04:04 wclr

What are the real use cases for using fetch vs installing and building the package?

People often want separate commands to just download the packages (which requires network) vs building them (which doesn't require network). I often use spago install to cache entire package sets if I know I'm going to be without network, and I've used and seen it used as a separate step in CI for separation of concerns.

Note: spago install does a different thing than spago install somepackage, which is why I'm proposing that we rename it to spago fetch

f-f avatar Apr 07 '21 11:04 f-f

The new Spago now does this, closing

f-f avatar Sep 20 '23 16:09 f-f