Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Attempting to install an unreleased package #4344

Closed
craigfe opened this issue Sep 7, 2020 · 3 comments
Closed

Attempting to install an unreleased package #4344

craigfe opened this issue Sep 7, 2020 · 3 comments
Milestone

Comments

@craigfe
Copy link

craigfe commented Sep 7, 2020

Given the following set of Opam files in a local directory:

# dependency.opam
opam-version: "2.0"
version: "0.1.0"

# unreleased.opam
opam-version: "2.0"
depends: [ "dependency" {= version} ]

Attempting to run a local install will fail:

❭ opam install --deps-only ./
The following dependencies couldn't be met:
  - unreleased → dependency < 0.1.0
      no matching version

No solution found, exiting

Pinning both packages to a common version such as dev fixes the problem (unfortunately, I don't think it's possible to do that in a single opam invocation). My questions are:

  • should it be possible to install a local .opam file without that file needing to be released in the repository? This is an issue when a new package has recently been added to a monorepo, but no release cycle has occurred yet. Perhaps opam should automatically pin such packages to dev when it encounters them?

  • regardless, the error message for this install is a bit opaque. Could it be improved to something like "No version of unreleased is available to install"?

CC: @pascutto

@AltGr
Copy link
Member

AltGr commented Sep 7, 2020

There is no problem with installing an unreleased package; let's first look at your error:
here, you specified in unreleased.opam a dependency to dependency at the same version, but without specifying the version of unreleased itself. Without any specific information to guess the version from, opam silently assumed version ~dev, so the constraint was resolved to "dependency" {= "~dev"}. The version constraint appearing in the error message is unfortunately slightly different (hence the confusion) due to intermediate rewritings, but basically equivalent.

Pinning both packages to a common version such as dev fixes the problem (unfortunately, I don't think it's possible to do that in a single opam invocation)

opam pin --with-version has just been added in #4301 for that purpose :)

should it be possible to install a local .opam file without that file needing to be released in the repository? This is an issue when a new package has recently been added to a monorepo, but no release cycle has occurred yet. Perhaps opam should automatically pin such packages to dev when it encounters them?

It sure is: just use opam pin <file>; you can also use opam pin --edit to interactively edit the opam file.

@craigfe
Copy link
Author

craigfe commented Sep 7, 2020

opam pin --with-version has just been added in #4301 for that purpose :)

Neat, thanks!

Without any specific information to guess the version from, opam silently assumed version ~dev, so the constraint was resolved to "dependency" {= "~dev"}.

It sure is: just use opam pin ; you can also use opam pin --edit to interactively edit the opam file.

Indeed; I suppose my point was that if Opam is going to assume a version for unreleased / unpinned packages then it might make sense for it to also prompt me to pin at that version. I'm happy either way, since pin --with-version makes manually pinning much more convenient now than it used to be 🙂

The version constraint appearing in the error message is unfortunately slightly different (hence the confusion) due to intermediate rewritings, but basically equivalent.

Do you think it's possible to alter the error message here so that the user is more aware of this intermediate step?

@AltGr
Copy link
Member

AltGr commented Jan 15, 2021

Messages have improved and are still being worked on; the options to set the pinning version have been added so I think this can be closed. Thanks for reporting!

@AltGr AltGr closed this as completed Jan 15, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants