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

How to use Cabal in Windows #9723

Merged
merged 1 commit into from
May 5, 2024
Merged

Conversation

jasagredo
Copy link
Collaborator

This is my humble attempt at providing some documentation for how to use GHC and Cabal in Windows. It aims to resolve #9713 , however all I wrote here is based on my experience and might not be The Correct Way To Do Things ™️. I could use some thorough reviews.

Copy link

@endgame endgame left a comment

Choose a reason for hiding this comment

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

I'm not on the Cabal team and I haven't used Windows for years, but this feels important enough that I didn't want it to sit unreviewed. It's great that you wrote this, and I think with a bit of focusing on the intended reader, it'll be a very useful addition to the manual.

Overall, I think it's important to keep the main reader of this document in mind: someone who has just installed Haskell (probably through GHCup) and needs to get cabal working. They will be very frustrated if things appear to work but then mysterious msys failures cause breakage the first time they build a package that wants to run a ./configure script or do unixy things.

I think information which supports that goal should come first, and each section can drill into the details as much as is necessary. I get the sense that this PR contains a lot of hard-won knowledge; while it's good to have those details written down somewhere, I believe the main reader of a document like this will want to just get cabal going (and may drill down if things aren't working right).

doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
@Kleidukos
Copy link
Member

@bradrn would you mind taking a look?

@bradrn
Copy link

bradrn commented Feb 17, 2024

Thanks for the reminder! I’ll read through it later today.

Copy link
Member

@hasufell hasufell left a comment

Choose a reason for hiding this comment

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

In general, I'm mildly skeptical of the current version of this PR.

I do not like the idea that cabal documentation provides extensive information about how GHCup does things, how to install it and run it. That is in the GHCup documenation. Let's please keep things separate.

In addition, I find this is quite verbose and the main information (adding things to extra-include-dirs, extra-lib-dirs and extra-prog-path) is way too far down.

The information about adjusting PATH I consider incorrect.

doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
Copy link

@bradrn bradrn left a comment

Choose a reason for hiding this comment

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

Just read through this document. In general, I agree with @hasufell: this is overly long, poorly structured, covers many extraneous details, and contains some recommendations which may be actively harmful. To me, it reads more like ‘my recommendations for using Haskell on Windows’, rather than something which can be included in Cabal documentation.

However, I think it’s salvageable. I may try to condense this into a shorter and more focussed guide, then make my own PR.

EDIT: To make myself clear, I don’t think this is a bad document necessarily. It would make a fine standalone article. It’s just that it’s wider in scope than is necessary for Cabal-specific documentation.

@jasagredo
Copy link
Collaborator Author

I tried to build up the information step by step, first with GHC alone then with cabal. I think that although it is at the end of the document, a user first checks the list of subsections, at least that is what I would do.

I kind of prefer to be extra verbose, explain too many things but still have things explained somewhere. I'm unaware of a resource that tells you how to use Haskell on Windows, the closest thing is GHC wiki pages which are either outdated or talk only about how to build GHC alone on windows.

However if one doesn't feel that way, I can see how this can be seen as too verbose and overly specific for the Cabal documentation. I will trim it down.

In terms of Documentation relevant to Cabal, I'm unsure then what to mention. I propose the following:

  1. Install via ghcup. Refer to its documentation.
  2. Libraries need to be visible in extra-lib-dirs. Includes need to be visible in extra-include-dirs. Unix tools need to be visible in extra-prog-path. Ghcup takes care of it for you.
  3. End

I will try to answer why I chose to write the chunks where questions were asked above.

@bradrn
Copy link

bradrn commented Feb 17, 2024

  1. Install via ghcup. Refer to its documentation.
  2. Libraries need to be visible in extra-lib-dirs. Includes need to be visible in extra-include-dirs. Unix tools need to be visible in extra-prog-path. Ghcup takes care of it for you.
  3. End

I don’t think GHCup should be described at all, except insofar as the docs need to mention that it might provide an MSYS2 installation. GHCup-specific stuff goes in GHCup’s documentation. (Which already has a Windows section, incidentally, but it needs expansion.)

@jasagredo
Copy link
Collaborator Author

@bradrn @hasufell @endgame First of all, kindly thank you for your reviews.

I have pushed another commit that fully re-does the document, this time limiting myself to mention the things that seem relevant to "what do I need to do to run Cabal on windows". I omitted side explanations on why are things as they are or giving context on what is being used underneath and why.

I hope this looks more suitable for the Cabal documentation.

@bradrn
Copy link

bradrn commented Feb 17, 2024

As it happens, I’ve been working on my own version of this document. I’m no longer going to submit it as its own PR, since I believe @jasagredo’s new version is superior. However, if there’s anything I’ve written there which looks useful to integrate into this PR, feel free to copy it over!

@jasagredo
Copy link
Collaborator Author

@bradrn I would not mention that it is strongly recommended to use the installations that come with GHCup and Stack. If a user only wants to do Haskell on their machine then maybe, but what if you want to install an editor such as Emacs by compiling it in MSYS2? Or do work in some other language? Must I be using the GHCup MSYS2? I don't think so.

@bradrn
Copy link

bradrn commented Feb 17, 2024

@bradrn I would not mention that it is strongly recommended to use the installations that come with GHCup and Stack.

I meant, of course, for Haskell-specific work. I assumed that was clear from context.

What I’d like to avoid is the situation where someone installs GHCup, then sees that it can integrate with MSYS2 so they go and install MSYS2 separately. The end result is that they’ve mistakenly ended up with an MSYS2 installation which GHCup doesn’t know about, which could get confusing.

@jasagredo
Copy link
Collaborator Author

jasagredo commented Feb 17, 2024

Indeed. That is what I tried to explain before by saying that GHCup can work with an existing MSYS2 and trying to outline how to do so.

However it seems this is out of the scope for the Cabal documentation. I might file a ticket to GHCup to mention this then.

In general my previous write up assumed that the general user is not only going to do Haskell work in Windows, hence why I focused on providing instructions that would work for an existing MSYS2. But as you say, this is probably not the context in which Haskell is used or what is expected from the Cabal documentation. It seems Haskell/Cabal should try to isolate as much as possible from other tools or developer practices.

@bradrn
Copy link

bradrn commented Feb 17, 2024

However it seems this is out of the scope for the Cabal documentation. I might file a ticket to GHCup to mention this then.

This would be a good idea. I think it’s at least fair to mention in the Cabal documentation that Cabal requires knowing the location of MSYS2, and describe some places where it might be found.

I mean, for that matter, your latest version strongly recommends using GHCup in the first place. If that’s acceptable, then I think my recommendations certainly should be too.

@jasagredo
Copy link
Collaborator Author

Cabal requires knowing the location of MSYS2

This is only true if you happen to need something from MSYS2. If you are only compiling packages which do not rely on external tools then you don't need an MSYS2. So Cabal doesn't require knowing this. In fact it is the User the one that wants cabal to know these.

your latest version strongly recommends using GHCup in the first place

It recommends using GHCup to install a Haskell environment. I chose deliberately to defer the question about "what if I already have an MSYS2 installation?" to GHCup's documentation where it seems this should be mentioned. I tried to explain it here but this was widely rejected. To be clear I'm not saying that I recommend using GHCup's MSYS2. I might need to make this clear in the document but I don't know how to do so without stepping over what is said to be GHCup's business.

@bradrn
Copy link

bradrn commented Feb 17, 2024

Cabal requires knowing the location of MSYS2

This is only true if you happen to need something from MSYS2. If you are only compiling packages which do not rely on external tools then you don't need an MSYS2. So Cabal doesn't require knowing this. In fact it is the User the one that wants cabal to know these.

Aargh, imprecise wording again! Of course, this whole conversation is only relevant if you need to use external packages.

your latest version strongly recommends using GHCup in the first place

It recommends using GHCup to install a Haskell environment.

Yes, that’s what I was referring to. To me this seems a far stronger (and less relevant) statement than ‘use GHCup/Stack’s MSYS2 environment, if you’re using GHCup/Stack’.

@jasagredo
Copy link
Collaborator Author

jasagredo commented Feb 17, 2024

I have pushed a new version. This time changing the title, moving the line GHCup will install its own MSYS2 system in your computer unless told not to do so, refer to its documentation <https://www.haskell.org/ghcup/install/#windows_1>_ for more information. up and adding links to the global config discovery (thanks @bradrn for that one!).

I also squashed the intermediate commits.

doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
doc/how-to-run-in-windows.rst Outdated Show resolved Hide resolved
@Mikolaj
Copy link
Member

Mikolaj commented May 1, 2024

Dear all, can we move this forward? @jasagredo: what do you need from us at this point? More comments? Reviews? Formal review acceptance? All of the above?

@jasagredo
Copy link
Collaborator Author

I think I have addressed all the comments that arose during the reviews. I'm happy to expand this document a bit more if wanted, but I would need to know which directions should I expand it towards (debugging errors maybe?) although these could also be done in a follow-up PR.

So I think what I need is basically formal approvals, although reviews (even without approval) are also more than welcome 😄

@Kleidukos Kleidukos requested a review from bradrn May 2, 2024 09:47
@bradrn
Copy link

bradrn commented May 2, 2024

At a quick skim, this looks OK. Later today when I get time, I’ll read through it more carefully. (Ping me if I forget!)

One initial comment: in the first section it may be a good idea to mention Stack too, even if GHCup is strongly recommended.

@hasufell
Copy link
Member

hasufell commented May 3, 2024

In terms of using GHCup (rather than Stack) to manage versions of Stack, I don't embrace that myself - but that is because I am often building Stack from source and stack upgrade will overwrite the GHCup 'shim' executable named stack.

We could certainly fix that by providing a ghcup compile stack variant.

@jasagredo
Copy link
Collaborator Author

I spot a few places where phrasing could be slightly improved, but no major issues.

I'm not a native English speaker so my phrasing sometimes is not 100% correct. I will be more than happy to fix grammar/phrasing mistakes in this document should you point them out, or I happily would accept commits into this branch or a PR or something like that

@bradrn
Copy link

bradrn commented May 3, 2024

I will be more than happy to fix grammar/phrasing mistakes in this document should you point them out

OK, I’ll add some comments now.

@bradrn
Copy link

bradrn commented May 3, 2024

I think it’s all fine now. GitHub says it needs two approving reviews, but after that it’s ready to be merged (in my opinion).

@jasagredo jasagredo force-pushed the js/how-to-windows branch from 79ec5e1 to 0709350 Compare May 3, 2024 11:18
@jasagredo
Copy link
Collaborator Author

I have squashed the commits into one. Now only missing piece are approving reviews 👍

Thanks all!

Copy link
Member

@Kleidukos Kleidukos left a comment

Choose a reason for hiding this comment

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

My thanks to @bradrn for his review of this page

@Kleidukos Kleidukos requested a review from hasufell May 3, 2024 12:11
@jasagredo jasagredo force-pushed the js/how-to-windows branch from 0709350 to 7030037 Compare May 3, 2024 14:13
Copy link
Collaborator

@ffaf1 ffaf1 left a comment

Choose a reason for hiding this comment

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

pretty fantastic

@jasagredo jasagredo added the merge me Tell Mergify Bot to merge label May 3, 2024
@Mikolaj
Copy link
Member

Mikolaj commented May 4, 2024

Shall we backport this to 3.12, since this only expands (and plausibly fixes) documentation? I assume it does not describe anything that is on master branch, but not the 3.12 branch (which is master from 1 or 2 months ago)?

@jasagredo
Copy link
Collaborator Author

These are purely additions to the documentation, and the behavior described has not changed for a long time, so it is applicable to 3.12 (even to older versions). So if possible, backporting it would be nice.

@Mikolaj
Copy link
Member

Mikolaj commented May 4, 2024

@mergify backport 3.12

Copy link
Contributor

mergify bot commented May 4, 2024

backport 3.12

✅ Backports have been created

@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label May 5, 2024
@Mikolaj Mikolaj force-pushed the js/how-to-windows branch from 7030037 to 18b91cc Compare May 5, 2024 16:49
@mergify mergify bot merged commit f46dd08 into haskell:master May 5, 2024
14 checks passed
mergify bot added a commit that referenced this pull request May 5, 2024
How to use Cabal in Windows (backport #9723)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge me Tell Mergify Bot to merge platform: windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Windows] Document use and integration of MSYS2
10 participants