-
Notifications
You must be signed in to change notification settings - Fork 358
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
Installing and recording new dependencies in a single step #3615
Comments
There is something unclear... Why do you need to add the packages in the opam file and then regenerate the lock file? |
I'm not sure I understand the question — when I need to add a new dependency in my library, four things implicitly happen:
Does that answer your question? Happy to elaborate. |
I see better, thanks. afaik, it is not yet possible in opam to do it automatically (ping @AltGr?). An option
As it is a plugin, lock file generation can't be integrated. |
I definately think opam has some different considerations here than npm, so we shouldn't blindly copy their details. For me, the takeaway from npm is "automating this particular workflow is nice" — from there on out, the decisions will have to be OCaml / compiled-software specific. (In fact, I was just talking about the diffences between the Node and OCaml problem-space with @zkat as it pertains to npm copying opam's interactive-resolution mechanism!) Specifically to those points, here're my thoughts:
|
One thought I want to add: I touch on this above, but it seems to me that, in a way, the dependency-graph expressed in the In other words, could a separate dependency-resolution take place on |
Just bumping to show continued interest in the possibility of such a feature! (Also, I'm totally okay with scoping this down to just |
On the constraint persistence, I agree with you, but I have the feeling that not most of user uses those constraints: usually you install the package with no version, or you specify a specific one, while in the opam file, most of the time, constraints are not as (one specific version) strict. In this case, i'd say that it's the user that need to be more precise on version expression at install as it will be added in the opam file. On the "forgotten breaking new version", generally in that case you reinstall an older version of the incriminated package, plus it will be with a constraint, that will be directly integrated in the opam file. Otherwise, for every package that is already present, the need to open opam file and manually update remain, what minimizes the use of this option. i began a first draft of this option here, if you want to take a look. If you want to check that dependencies in your opam are coherent, you can test this by creating an empty switch (that can be used afterwards for those checks also)
and then when you want to check, you can run a fake install in this switch, whatever you current switch is
This will only check dependencies consistence, not installation status as it performs no real action. An easier way to modify you opam file without editing them is to use the package |
Also |
@ELLIOTTCABLE The feature is implemented in a plugin: |
At the moment, all dependencies must be encoded manually. In the OCaml ecosystem, that isn't too bad, just yet; but as opam 2.0 has started to make it a lot easier to build, develop, and publish multiple smaller/more focused packages, I imagine that will begin to shift.
As mentioned in #3606, one thing I'm really missing from my maintainer/contributor workflow in Node packages, is an equivalent of
--save
and--save-dev
: I'm currently having to install a package, watch what version opam decides to resolve it to, manually copy that version into myopam
file as a dependency, and then re-generate myopam.lock
. A bit of a verbose process!I'd love to see a behaviour to do all of this automatically — hopefully, one that includes sane SemVer defaults (see @whitequark's #2976?) for newly-installed packages, so that new users of my packages are likely to be protected from breaking changes I make as a default behaviour.
The text was updated successfully, but these errors were encountered: