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

cabal init crashes if git is not installed #10484

Closed
noiioiu opened this issue Oct 28, 2024 · 8 comments · Fixed by #10486
Closed

cabal init crashes if git is not installed #10484

noiioiu opened this issue Oct 28, 2024 · 8 comments · Fixed by #10486

Comments

@noiioiu
Copy link
Contributor

noiioiu commented Oct 28, 2024

Describe the bug
Running cabal init without git installed results in the following error:

git: readCreateProcessWithExitCode: execvp: does not exist (No such file or directory)

or

git: readCreateProcessWithExitCode: posix_spawnp: does not exist (No such file or directory)

To Reproduce
Run cabal init in an empty directory on a system without git installed or after setting $PATH to something that includes cabal and ghc but not git. Answer the prompts; the program will exit with the above error message after you choose a license.

Expected behavior
cabal init should continue running and ask for author name, email address, etc.

System information

  • cabal 3.10.3.0, ghc 9.6.5 on NixOs 24.05
  • cabal 3.12.1.0, ghc 9.6.6 on OpenBSD 7.6-current

Additional context
The function Distribution.Client.Init.NonInteractive.Heuristics.guessGitInfo uses readProcessWithExitCode, which throws an IOError which should be caught if the file is not found.

@geekosaur
Copy link
Collaborator

Huh. Supposedly this was fixed (#8478) unless I'm misreading.

@noiioiu
Copy link
Contributor Author

noiioiu commented Oct 28, 2024

No, it looks like the 'fix' only deals with the case where git fails.

readProcessWithExitCode only returns an ExitFailure if git runs and exits unsuccessfully. If git is not found at all, it throws an exception, which causes cabal to exit.

This should be easy to fix, it just requires catching the exceptions and returning Nothing.

@ffaf1
Copy link
Collaborator

ffaf1 commented Oct 28, 2024

@BasLaa will be able to diagnose quicker.

@noiioiu
Copy link
Contributor Author

noiioiu commented Oct 28, 2024

I have a draft pull request that might fix this.

@ulysses4ever ulysses4ever linked a pull request Oct 31, 2024 that will close this issue
5 tasks
@ulysses4ever
Copy link
Collaborator

Huh. Supposedly this was fixed (#8478) unless I'm misreading.

Haven't check in the code, but the catch maybe that #8478 talks about the non-interactive mode whereas this ticket is about interactive. Unfortunately, since at least the last init rewrite (it happened a couple of years ago), the two modes have very little code in common (in comparison to what one might expect).

@geekosaur
Copy link
Collaborator

I was misreading: that ticket fixed it when git was found but not configured. This one's about when git isn't found at all.

@ulysses4ever
Copy link
Collaborator

Did you read the description of #8478?

@ulysses4ever
Copy link
Collaborator

Maybe you're saying: #8755 didn't fix #8478 even though it claims that. That's sad but not surprising 'cause we didn't have a real integration test in #8755. We should do better this time around.

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.

4 participants