Skip to content

Fail when trying to pin a package whose definition could not be found instead of forcing interactive edition#6319

Merged
kit-ty-kate merged 2 commits intoocaml:masterfrom
kit-ty-kate:no-edit-pkg-not-found-pin
Apr 9, 2025
Merged

Fail when trying to pin a package whose definition could not be found instead of forcing interactive edition#6319
kit-ty-kate merged 2 commits intoocaml:masterfrom
kit-ty-kate:no-edit-pkg-not-found-pin

Conversation

@kit-ty-kate
Copy link
Copy Markdown
Member

@kit-ty-kate kit-ty-kate commented Nov 30, 2024

Closes #6322
This could happen with things like opam pin <typo> <url> or a typo in the pin-depends definition.

The interactive edition based on the dummy opam file template is now only allowed if the user is purposefully requesting it using --edit or opam pin edit.

@kit-ty-kate kit-ty-kate added this to the 2.4.0~alpha1 milestone Nov 30, 2024
@kit-ty-kate kit-ty-kate requested a review from rjbou November 30, 2024 19:11
OpamConsole.note
"No package definition found for %s: please complete the template"
(OpamConsole.colorise `bold (OpamPackage.to_string nv));
OpamFileTools.template nv
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really want to keep this template around? In which situation is it useful? I feel like it doesn't really has any purpose and we might want to remove it entirely (probably in a separate PR)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of an opam pin edit and there is no opam file (we want to create one)

@rjbou
Copy link
Copy Markdown
Collaborator

rjbou commented Dec 6, 2024

Discussion on dev meeting: Overall agreement on blocked CI issue. We can't set the editing only on non tty as it is used hackishly in several places (our test for ex.) with specific command in OPAMEDITOR (cp/sed/etc.).
This option was useful at the beginning of opam, to ease pinning packages that didn't have yet an opam file, but today almost all OCaml package have one. And if it is missing, it will mostly be added in the repository itself than just internally in users opam switch. But we need to keep the ability to do that, and opam pin add --edit can permit it.

@kit-ty-kate kit-ty-kate force-pushed the no-edit-pkg-not-found-pin branch 2 times, most recently from 6a1afb5 to ecf85c4 Compare February 22, 2025 12:43
@kit-ty-kate
Copy link
Copy Markdown
Member Author

@rjbou I'm not sure how to fix your test from #5471. Any ideas?

Copy link
Copy Markdown
Collaborator

@rjbou rjbou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the general implem, LGTM! some small remarks

OpamConsole.note
"No package definition found for %s: please complete the template"
(OpamConsole.colorise `bold (OpamPackage.to_string nv));
OpamFileTools.template nv
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of an opam pin edit and there is no opam file (we want to create one)

OpamFile.OPAM.(with_metadata_dir (metadata_dir opam_base))
else
Some opam_base
Option.map (OpamFile.OPAM.with_url_opt urlf) opam_opt
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we update url here, do we still need lines 600-604 ?

   let opam =
      match OpamFile.OPAM.get_url opam with
      | Some _ -> opam
      | None -> OpamFile.OPAM.with_url_opt urlf opam
    in

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. That was also the case in the code before this PR but it's always good to clean redundant code ^^

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in follow up fixup commit

Copy link
Copy Markdown
Member Author

@kit-ty-kate kit-ty-kate Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually looking at it more after the reftests failed, this wasn't redundant after all.

When editing users can remove the url part so a check after always needs to happen, and when not editing we want to force the url to be urlf.

I removed that fixup commit.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough

@kit-ty-kate kit-ty-kate force-pushed the no-edit-pkg-not-found-pin branch from 7cc951b to 4b42c86 Compare April 8, 2025 22:02
@kit-ty-kate kit-ty-kate merged commit a252479 into ocaml:master Apr 9, 2025
44 checks passed
@kit-ty-kate kit-ty-kate deleted the no-edit-pkg-not-found-pin branch April 9, 2025 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stuck when pinning non-existent package

2 participants