Skip to content

Git-for-Windows opam init menu repeatedly asks the user to do the same #5835

Closed
@dra27

Description

@dra27

When run on a vanilla Windows system (without Git for Windows, etc.) opam init presents the user with:

C:\Users\DRA>opam init
No configuration file found, using built-in defaults.

<><> Git ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
Cygwin Git is functional but can have credentials issues for private repositories, we recommend using:
  - Install via 'winget install Git.Git'
  - Git for Windows can be downloaded and installed from https://gitforwindows.org

Which Git should opam use?
> 1. Use default Cygwin Git
  2. Enter the location of Git
  3. Abort initialisation to install Git manually.

So, I'm a reasonably good user, and I do at least read the first bit and so choose option 3 and get told:

[NOTE] When your chosen Git is installed, open a new PowerShell or Command Prompt window, and re-run opam init.

I run winget install Git.Git which scrolls that message up a bit. I'm not that good a user, so of course I forget to restart my shell and run opam init to be presented with the same menu. I scratch my ever-balding head at getting the same menu, and select option 3 to go and check whether winget actually worked. This time I see the note and remember that I forgot to restart the terminal. So I do that, and run opam init again:

C:\Users\DRA>opam init
No configuration file found, using built-in defaults.

<><> Git ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
Cygwin Git is functional but can have credentials issues for private repositories, we recommend using:
  - Install via 'winget install Git.Git'
  - Git for Windows can be downloaded and installed from https://gitforwindows.org

Which Git should opam use?
> 1. Use default Cygwin Git
  2. Use found git in C:\Program Files\Git\cmd
  3. Enter the location of Git
  4. Abort initialisation to install Git manually.

[1/2/3/4]

The default option selected goes against the recommendation, despite the fact that option 2 is actually Git-for-Windows.

We're asking the user to do something and then, when they've done it, we're still asking them to do it... I don't think we should ship with while true do () done in opam init 🙂

There are three changes which ought to be made:

  • If git is found in PATH (and it's not from Scoop, etc. - i.e. bash is not also there), and it's demonstrably Git-for-Windows, opam should just say [NOTE] Found Git-for-Windows <version> in PATH at <path> - good! and carry on.
  • If no git is found, the default option should be "3" so that the enter-hitting, non-message reading user gets back to their prompt and is forced to read what opam init said...
  • If the first git in PATH is "bad" (i.e. contains bash.exe) then opam should explain a bit harder about the PATH adjustments it needs to make, and do some additional searching for Git-for-Windows

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions