Skip to content
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

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

Closed
dra27 opened this issue Feb 12, 2024 · 1 comment · Fixed by #5963
Closed

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

dra27 opened this issue Feb 12, 2024 · 1 comment · Fixed by #5963
Assignees

Comments

@dra27
Copy link
Member

dra27 commented Feb 12, 2024

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
@dra27 dra27 self-assigned this Feb 12, 2024
@dra27
Copy link
Member Author

dra27 commented Feb 12, 2024

I have WIP (but not far enough done for a draft PR) on this related to #5832 - the issue is intended to ensure it doesn't get forgotten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants