unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to *properly* set up Emacs on Windows?
@ 2022-02-08 17:06 Joost
  2022-02-08 18:52 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Joost @ 2022-02-08 17:06 UTC (permalink / raw)
  To: help-gnu-emacs

Hi list,

I've recently had to set up Emacs on Windows, having used it for over two decades on Linux exclusively. Unfortunately, I'm constantly running into small issues that give me the impression there's something wrong with my setup, but unfortunately I haven't been able to figure out what exactly.

So, the tl;dr of it is this: What would I need to do to get Emacs running on Windows in such a way that easily access utilities such as git, diff and hopefully a few more (ag or rg would be nice, gcc and libgccjit for when I decide to move to Emacs 28) from within Emacs, and also have a graphical Emacs?

The thing that prompted me to post this message is that I ran into the issue described here:

https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-05/msg01296.html

In short, the variable `package-gnupghome-dir` is set to "c:/Users/joost.kremers/.emacs.d/elpa/gnupg", but when I try to install / update packages, I get an error saying:

keyblock resource '/c/Users/joost.kremers/.emacs.d/elpa/c:/Users/joost.kremers/.emacs.d/elpa/gnupg/pubring.kbx': No such file or directory

Note the path.

I can set `package-gnupghome-dir` to "/c/Users/joost.kremers/.emacs.d/elpa/gnupg" and that will fix this issue, but it doesn't feel like it's the right solution.

Eli Zaretski's comment in the message I linked to most likely applies to my
case: "Looks like you are mixing MSYS2 executables and native Windows (a.k.a.
"MinGW") executables [...]".

To be honest, though, I'm not entirely sure how I got myself into that situation. I don't even have a good understanding of MSYS2 and MinGW and the differences between them.

I *think* it happened when I tried to use some external utilities from within Emacs, mainly git and diff, for which I modified my PATH variable.

So, does anyone have any advice on how to get out of this situation and get a better Emacs setup on Windows? Any and all hints very much appreciated!

TIA

Joost



-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: How to *properly* set up Emacs on Windows?
  2022-02-08 17:06 How to *properly* set up Emacs on Windows? Joost
@ 2022-02-08 18:52 ` Eli Zaretskii
  2022-02-09  8:14   ` Joost
  2022-02-08 20:02 ` Óscar Fuentes
  2022-02-09 12:28 ` Arash Esbati
  2 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-02-08 18:52 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Tue, 08 Feb 2022 18:06:36 +0100
> From: Joost <joostkremers@fastmail.fm>
> 
> https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-05/msg01296.html
> 
> In short, the variable `package-gnupghome-dir` is set to "c:/Users/joost.kremers/.emacs.d/elpa/gnupg", but when I try to install / update packages, I get an error saying:
> 
> keyblock resource '/c/Users/joost.kremers/.emacs.d/elpa/c:/Users/joost.kremers/.emacs.d/elpa/gnupg/pubring.kbx': No such file or directory
> 
> Note the path.
> 
> I can set `package-gnupghome-dir` to "/c/Users/joost.kremers/.emacs.d/elpa/gnupg" and that will fix this issue, but it doesn't feel like it's the right solution.
> 
> Eli Zaretski's comment in the message I linked to most likely applies to my
> case: "Looks like you are mixing MSYS2 executables and native Windows (a.k.a.
> "MinGW") executables [...]".
> 
> To be honest, though, I'm not entirely sure how I got myself into that situation. I don't even have a good understanding of MSYS2 and MinGW and the differences between them.
> 
> I *think* it happened when I tried to use some external utilities from within Emacs, mainly git and diff, for which I modified my PATH variable.
> 
> So, does anyone have any advice on how to get out of this situation and get a better Emacs setup on Windows? Any and all hints very much appreciated!

Here's my advice:

  . Completely segregate MSYS2 from the native Windows applications.
    Don't add the MSYS2 bin directory to your system-wide Path, and
    have Path only reference directories with native Windows and MinGW
    executables.

  . If you need some Unix application to be callable from Emacs,
    always try to find a native Windows port of it; do NOT be tempted
    to install an MSYS2 port.  (Note that the MSYS2 project
    distributes both MSYS2 ports and MinGW64 ports, so you need to be
    aware of what you install.  Unfortunately, some packages exist
    only as MSYS2 apps, because no one ported them to MinGW.)

  . The above policy will not work with Git, because it _must_ be able
    to call the MSYS2 Bash and other MSYS2 programs.  If you want to
    invoke Git from Emacs, have a git.cmd batch file on your Path
    which will use SETLOCAL to add Git's bin directory to Path
    temporarily, for the duration of the Git command, and invoke
    git.exe.  This will work for most simple Git commands; for more
    complex Git commands that don't work from Emacs, use Git Bash
    window to invoke them, and set up emacsclient to be the EDITOR for
    Git commands instead.

  . If you need to build MinGW programs by running Posix Autoconf
    stuff, do that from a dedicated Bash window, which is set up to
    use the MSYS2 directories in PATH ahead of the native bin
    directories.

The difference between MSYS2 programs and native/MinGW programs is
that the former needs the msys-2.0.dll to run, and they use that DLL
to provide a layer of Posix compatibility on top of Windows.  The side
effect of that Posix layer is that some operations related to I/O,
consoles, subprocesses, and signals are expected by the MSYS2
applications to work differently, and therefore their compatibility
with native applications is lower.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: How to *properly* set up Emacs on Windows?
  2022-02-08 17:06 How to *properly* set up Emacs on Windows? Joost
  2022-02-08 18:52 ` Eli Zaretskii
@ 2022-02-08 20:02 ` Óscar Fuentes
  2022-02-09  8:48   ` Joost
  2022-02-09 12:28 ` Arash Esbati
  2 siblings, 1 reply; 14+ messages in thread
From: Óscar Fuentes @ 2022-02-08 20:02 UTC (permalink / raw)
  To: help-gnu-emacs

Joost <joostkremers@fastmail.fm> writes:

> So, the tl;dr of it is this: What would I need to do to get Emacs
> running on Windows in such a way that easily access utilities such as
> git, diff and hopefully a few more (ag or rg would be nice, gcc and
> libgccjit for when I decide to move to Emacs 28) from within Emacs,
> and also have a graphical Emacs?
>
> The thing that prompted me to post this message is that I ran into the
> issue described here:
>
> https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-05/msg01296.html
>
> In short, the variable `package-gnupghome-dir` is set to
> "c:/Users/joost.kremers/.emacs.d/elpa/gnupg", but when I try to
> install / update packages, I get an error saying:
>
> keyblock resource '/c/Users/joost.kremers/.emacs.d/elpa/c:/Users/joost.kremers/.emacs.d/elpa/gnupg/pubring.kbx': No such file or directory
>
> Note the path.

Yes, it seems that MSYS2 got involved there.

> I can set `package-gnupghome-dir` to
> "/c/Users/joost.kremers/.emacs.d/elpa/gnupg" and that will fix this
> issue, but it doesn't feel like it's the right solution.

Why do you need to set package-gnupghome-dir at all?

> Eli Zaretski's comment in the message I linked to most likely applies
> to my case: "Looks like you are mixing MSYS2 executables and native
> Windows (a.k.a. "MinGW") executables [...]".
>
> To be honest, though, I'm not entirely sure how I got myself into that
> situation. I don't even have a good understanding of MSYS2 and MinGW
> and the differences between them.

MSYS2 is a Cygwin fork, so it is a POSIX emulation system, with some
features to interoperate with the rest of the Windows world. Those
features sometimes help, sometimes hurt.

MinGW produces "native" Windows stuff, therefore MinGW executables, as
any other regular Windows executable, do not understand MSYS2/Cygwin
POSIX paths like your "/c/Users/..." (which actually is a concatenation
of a POSIX path and a Windows PATH, because of the later "c:/Users..".

> I *think* it happened when I tried to use some external utilities from
> within Emacs, mainly git and diff, for which I modified my PATH
> variable.

First of all, undo those changes to PATH and any other change to .emacs
related to Windows support.

MSYS2 provides many utilities as MinGW packages.

For instance, if you installed emacs with:

$ pacman -S mingw-w64-x86_64-emacs

you should install those utilities as:

$ pacman -S mingw-w64-x86_64-grep
$ pacman -S mingw-w64-x86_64-diffutils
$ pacman -S mingw-w64-x86_64-ag

For communicating with ELPA:

$ pacman -S mingw-w64-x86_64-gnupg

For nativecomp support:

$ pacman -S mingw-w64-x86_64-libgccjit

You can use

$ pacman -Ss text

for listing packages that contain "text" on their name or description.

MSYS2 does not provide git as a MinGW package, so you have two options:
either install the MSYS2 package (pacman -S git) or install "Git for
Windows", which provide an almost native port. If the later, the
installer will ask if you want its executables added to PATH, either all
or just git.exe. My advice is to not modify PATH or to add just git.exe.
You can set vc-git-program to where git.exe is and VC will work without
git.exe on PATH.

If you opt for installing git from MSYS2, set vc-git-program. Do not add
MSYS2 /bin directory to PATH.

If you are a Magit user, you can also set magit-git-executable.

Now, a very important detail. Emacs does not follow the Windows
convention of searching executables from the current process' directory.
This means that you must explicitly tell Emacs where to look for all
those utilities. You can add c:\msys64\mingw64\bin (change it if you
installed MSYS2 elsewhere) to PATH or set PATH directly within Emacs:

(let ((dir invocation-directory))
  (setenv "PATH" (concat (getenv "PATH") path-separator dir))
  (setq exec-path (append exec-path (list dir))))))

It is important that emacs.exe bin is listed before any other directory
that may contain conflicting executables, so let's put it at the front
just in case.

You shouldn't need further modifications to your .emacs or to the
environment (*), so ask here before adding something else.

* If you want to use Git through ssh you need to setup a SSH client and
  tell Git about its existence, but that is unrelated to Emacs.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: How to *properly* set up Emacs on Windows?
  2022-02-08 18:52 ` Eli Zaretskii
@ 2022-02-09  8:14   ` Joost
  2022-02-09 14:04     ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Joost @ 2022-02-09  8:14 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Eli,

Thanks for your answer, it certainly cleared up some questions I had. Still, I'm not sure what to do about git.

On Tue, 8 Feb 2022, at 19:52, Eli Zaretskii wrote:
>   . The above policy will not work with Git, because it _must_ be able
>     to call the MSYS2 Bash and other MSYS2 programs.  If you want to
>     invoke Git from Emacs, have a git.cmd batch file on your Path
>     which will use SETLOCAL to add Git's bin directory to Path
>     temporarily, for the duration of the Git command, and invoke
>     git.exe.  This will work for most simple Git commands; for more
>     complex Git commands that don't work from Emacs, use Git Bash
>     window to invoke them, and set up emacsclient to be the EDITOR for
>     Git commands instead.

I use magit on Linux, and have so far continued to do so on Windows, even though it's extremely slow (apparently a known problem.) Git itself is installed from <https://gitforwindows.org/>, which adds to my confusion, because it is apparently a separate (and minimal) MSYS2 installation, which one is advised to keep separate from a "normal" MSYS2 installation. In order to use it inside Emacs, I add "C:/Program Files/Git/usr/bin" to `exec-path` (it's not in my system path). Does that make sense?


-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: How to *properly* set up Emacs on Windows?
  2022-02-08 20:02 ` Óscar Fuentes
@ 2022-02-09  8:48   ` Joost
  2022-02-09 11:22     ` H. Dieter Wilhelm
  2022-02-09 13:19     ` Óscar Fuentes
  0 siblings, 2 replies; 14+ messages in thread
From: Joost @ 2022-02-09  8:48 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Óscar,

Thanks for your elaborate answer. It clears up some questions, but unfortunately also raises a few:

On Tue, 8 Feb 2022, at 21:02, Óscar Fuentes wrote:
>> I can set `package-gnupghome-dir` to
>> "/c/Users/joost.kremers/.emacs.d/elpa/gnupg" and that will fix this
>> issue, but it doesn't feel like it's the right solution.
>
> Why do you need to set package-gnupghome-dir at all?

I didn't set the original value with the Windows-style path, that was done automatically. I tried the POSIX-style path just to see if it worked. (There's a StackExchange answer somewhere suggesting this, but I posted here because I didn't think this was the right way to go about it.)

>> I *think* it happened when I tried to use some external utilities from
>> within Emacs, mainly git and diff, for which I modified my PATH
>> variable.
>
> First of all, undo those changes to PATH and any other change to .emacs
> related to Windows support.

I had C:/msys64/usr/bin in my system PATH and replaced it with C:/msys64/mingw64/bin. The only other change I made was to add C:/Program Files/Git/usr/bin to `exec-path` in Emacs, in order to use git from <https://gitforwindows.org/>.

> MSYS2 provides many utilities as MinGW packages.
>
> For instance, if you installed emacs with:
>
> $ pacman -S mingw-w64-x86_64-emacs

I didn't, I installed Emacs from gnu.org (installed to C:/Program\
Files/emacs-27.2-x86_64/). Would there be an advantage in installing Emacs with
pacman instead? Will that give me a graphical Emacs or just a console one?

> you should install those utilities as:
>
> $ pacman -S mingw-w64-x86_64-grep
> $ pacman -S mingw-w64-x86_64-diffutils
> $ pacman -S mingw-w64-x86_64-ag

Any point in installing those given that I didn't install Emacs with pacman? Can they be used with Emacs from gnu.org?

> For communicating with ELPA:
>
> $ pacman -S mingw-w64-x86_64-gnupg

Currently, after modifying the system PATH as described above, I can install packages from GNU Elpa again (Melpa was never a problem).

> For nativecomp support:
>
> $ pacman -S mingw-w64-x86_64-libgccjit

Is there an Emacs 28 pretest available that will work with this? (The Windows binaries that were anounced on emacs-devel the other day appear to be MSYS2 binaries? And `pacman -Ss emacs` doesn't return any Emacs 28 packages.)

> MSYS2 does not provide git as a MinGW package, so you have two options:
> either install the MSYS2 package (pacman -S git) or install "Git for
> Windows", which provide an almost native port.

I'm using the latter and added "C:/Program Files/Git/usr/bin" to `exec-path`, as mentioned above. Wrong decision?

> If you are a Magit user, you can also set magit-git-executable.

OK, I can try that instead.

> Now, a very important detail. Emacs does not follow the Windows
> convention of searching executables from the current process' directory.
> This means that you must explicitly tell Emacs where to look for all
> those utilities. You can add c:\msys64\mingw64\bin (change it if you
> installed MSYS2 elsewhere) to PATH or set PATH directly within Emacs:

I've now added that directory to the system PATH.

> You shouldn't need further modifications to your .emacs or to the
> environment (*), so ask here before adding something else.

I've been using Git Bash (alongside eshell) as my shell of choice. Would the MinGW-x64 shell provided by MSYS2 be a better choice? Or doesn't it really matter?

Thanks!

Joost


-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: How to *properly* set up Emacs on Windows?
  2022-02-09  8:48   ` Joost
@ 2022-02-09 11:22     ` H. Dieter Wilhelm
  2022-02-09 13:19     ` Óscar Fuentes
  1 sibling, 0 replies; 14+ messages in thread
From: H. Dieter Wilhelm @ 2022-02-09 11:22 UTC (permalink / raw)
  To: Joost; +Cc: help-gnu-emacs

Joost <joostkremers@fastmail.fm> writes:

> Is there an Emacs 28 pretest available that will work with this? (The
> Windows binaries that were anounced on emacs-devel the other day
> appear to be MSYS2 binaries? And `pacman -Ss emacs` doesn't return any
> Emacs 28 packages.)

Please check

  http://alpha.gnu.org/gnu/emacs/pretest/windows/emacs-28/

These Windows binaries were build with MSYS2 but don't need MSYS to run.
Please read nt/README{.W64} and nt/INSTALL{.W64} for further
information.

> I've been using Git Bash (alongside eshell) as my shell of
> choice. Would the MinGW-x64 shell provided by MSYS2 be a better
> choice? Or doesn't it really matter?

As far as I understand, Git Bash is based on MSYS2.  (I'm now using
exclusively the MSYS2 shell, instead of the Git Bash shell..:-))

   Dieter
-- 
Best wishes
H. Dieter Wilhelm
Zwingenberg, Germany



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: How to *properly* set up Emacs on Windows?
  2022-02-08 17:06 How to *properly* set up Emacs on Windows? Joost
  2022-02-08 18:52 ` Eli Zaretskii
  2022-02-08 20:02 ` Óscar Fuentes
@ 2022-02-09 12:28 ` Arash Esbati
  2 siblings, 0 replies; 14+ messages in thread
From: Arash Esbati @ 2022-02-09 12:28 UTC (permalink / raw)
  To: Joost; +Cc: help-gnu-emacs

Joost <joostkremers@fastmail.fm> writes:

> To be honest, though, I'm not entirely sure how I got myself into that
> situation. I don't even have a good understanding of MSYS2 and MinGW
> and the differences between them.

Others gave more elaborate answers, but for me as a not versed user, it
always worked to ignore MSYS2 when I was looking for binaries to use and
just searched for their MinGW versions.

> I *think* it happened when I tried to use some external utilities from
> within Emacs, mainly git and diff, for which I modified my PATH
> variable.
>
> So, does anyone have any advice on how to get out of this situation
> and get a better Emacs setup on Windows? Any and all hints very much
> appreciated!

Here is the way I set it up:

- Don't touch Windows $PATH and make any additions to it
- Only set $HOME (or %HOME% to be in Windows parlance) as a system-wide
  variable to a directory of your choice
- Install the portable version of Msys2, here the latest version[1]
- In the install directory, double click 'msys2_shell.cmd', let is run
  its opening ceremony, and do 'pacman -Syu'
- In your $HOME, touch .bash_profile and put things you want to have in
  it.  For example, I use Ghostscript installed on my C drive, and this
  is what I have:
    export PATH=$PATH:/c/Program\ Files/gs/gs9.55.0/bin
    export PATH=$PATH:/c/Program\ Files/gs/gs9.55.0/lib
- Install Emacs from a source of your choice (or even compile it
  yourself) and add an entry to $PATH like above
- In your Msys2 install directory, double click 'mingw64.exe' and then
  'emacs &' to see if it all works
- If you're happy, then start dropping wintty and use another terminal;
  I'm currently using Windows Terminal and I'm quite happy with it

N.B. I was never fond of setting environment variables within Emacs, so
I set everything in the shell and then start Emacs from it.  So I have
no "Shortcut to Emacs" on the desktop.

Reg. Git: I use git provided by Msys2.  It works for my workflow, but I
don't use Magit, so I can't tell how it goes.

HTH.  Best, Arash

Footnotes:
[1] https://github.com/msys2/msys2-installer/releases/download/2022-01-28/msys2-base-x86_64-20220128.tar.xz  



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: How to *properly* set up Emacs on Windows?
  2022-02-09  8:48   ` Joost
  2022-02-09 11:22     ` H. Dieter Wilhelm
@ 2022-02-09 13:19     ` Óscar Fuentes
  2022-02-10 21:58       ` Joost Kremers
  1 sibling, 1 reply; 14+ messages in thread
From: Óscar Fuentes @ 2022-02-09 13:19 UTC (permalink / raw)
  To: help-gnu-emacs

Joost <joostkremers@fastmail.fm> writes:

>> MSYS2 provides many utilities as MinGW packages.
>>
>> For instance, if you installed emacs with:
>>
>> $ pacman -S mingw-w64-x86_64-emacs
>
> I didn't, I installed Emacs from gnu.org (installed to C:/Program\
> Files/emacs-27.2-x86_64/). Would there be an advantage in installing Emacs with
> pacman instead?

Convenience and reliability.

> Will that give me a graphical Emacs or just a console one?

A graphical one, of course.

>> you should install those utilities as:
>>
>> $ pacman -S mingw-w64-x86_64-grep
>> $ pacman -S mingw-w64-x86_64-diffutils
>> $ pacman -S mingw-w64-x86_64-ag
>
> Any point in installing those given that I didn't install Emacs with
> pacman?

Well, AFAIK grep et al. are not included on GNU's package, so if you
want to use those utilities, you must install them from somewhere.

>Can they be used with Emacs from gnu.org?

The standalone tools (grep, diff, ag, etc) yes. The shared libraries
(libgccjit) may be problematic, if the MinGW packages distributed by
MSYS2 drift from what was used to build the GNU Emacs binary package.

>> For communicating with ELPA:
>>
>> $ pacman -S mingw-w64-x86_64-gnupg
>
> Currently, after modifying the system PATH as described above, I can
> install packages from GNU Elpa again (Melpa was never a problem).

Then I reckon that you have gnupg somewhere on your PATH.

>> For nativecomp support:
>>
>> $ pacman -S mingw-w64-x86_64-libgccjit
>
> Is there an Emacs 28 pretest available that will work with this?

No, MSYS2/MinGW tries to distribute released versions. Once Emacs 28 is
released, binary packages will be available from MSYS2 repos after a few
days.

> (The
> Windows binaries that were anounced on emacs-devel the other day
> appear to be MSYS2 binaries?

I don't think so.

> And `pacman -Ss emacs` doesn't return any Emacs 28 packages.)

Only one version of a given package is available on pacman at any give
time, except for cases that don't concern us.

>> MSYS2 does not provide git as a MinGW package, so you have two options:
>> either install the MSYS2 package (pacman -S git) or install "Git for
>> Windows", which provide an almost native port.
>
> I'm using the latter and added "C:/Program Files/Git/usr/bin" to
> `exec-path`, as mentioned above. Wrong decision?

I'll prefer to set vc-git-program. There are lots of files on that
directory. Now that I think of it, probably you are unknowingly using
gnupg from there. If you remove "C:/Program Files/Git/usr/bin" and GNU
Elpa stops working, install mingw-w64-x86_64-gnupg with pacman.

>> You shouldn't need further modifications to your .emacs or to the
>> environment (*), so ask here before adding something else.
>
> I've been using Git Bash (alongside eshell) as my shell of choice.
> Would the MinGW-x64 shell provided by MSYS2 be a better choice? Or
> doesn't it really matter?

The shell provided by MSYS2 works on top of the POSIX emulation layer.
If you know the implications and is what suits you, fine. If not, I'll
use Eshell alone, as it makes a decent cross-platform experience.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: How to *properly* set up Emacs on Windows?
  2022-02-09  8:14   ` Joost
@ 2022-02-09 14:04     ` Eli Zaretskii
  2022-02-10 21:05       ` Joost Kremers
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2022-02-09 14:04 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Wed, 09 Feb 2022 09:14:20 +0100
> From: Joost <joostkremers@fastmail.fm>
> 
> >   . The above policy will not work with Git, because it _must_ be able
> >     to call the MSYS2 Bash and other MSYS2 programs.  If you want to
> >     invoke Git from Emacs, have a git.cmd batch file on your Path
> >     which will use SETLOCAL to add Git's bin directory to Path
> >     temporarily, for the duration of the Git command, and invoke
> >     git.exe.  This will work for most simple Git commands; for more
> >     complex Git commands that don't work from Emacs, use Git Bash
> >     window to invoke them, and set up emacsclient to be the EDITOR for
> >     Git commands instead.
> 
> I use magit on Linux, and have so far continued to do so on Windows, even though it's extremely slow (apparently a known problem.) Git itself is installed from <https://gitforwindows.org/>, which adds to my confusion, because it is apparently a separate (and minimal) MSYS2 installation, which one is advised to keep separate from a "normal" MSYS2 installation. In order to use it inside Emacs, I add "C:/Program Files/Git/usr/bin" to `exec-path` (it's not in my system path). Does that make sense?

Yes: don't do that!  Git/usr/bin is a directory where MSYS2 programs
used by Git are kept; you do NOT want them on your exec-path.  That's
exactly why I wrote the above exception for Git.  Óscar mentioned 2
other possible arrangements:

> MSYS2 does not provide git as a MinGW package, so [...] install "Git for
> Windows", which provide an almost native port. [...] the
> installer will ask if you want its executables added to PATH, either all
> or just git.exe. My advice is to not modify PATH or to add just git.exe.
> You can set vc-git-program to where git.exe is and VC will work without
> git.exe on PATH.

Any of these alternatives will save you from introducing MSYS2
programs into your exec-path, and will avoid the kind of problems you
encountered.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: How to *properly* set up Emacs on Windows?
  2022-02-09 14:04     ` Eli Zaretskii
@ 2022-02-10 21:05       ` Joost Kremers
  0 siblings, 0 replies; 14+ messages in thread
From: Joost Kremers @ 2022-02-10 21:05 UTC (permalink / raw)
  To: help-gnu-emacs


On Wed, Feb 09 2022, Eli Zaretskii wrote:
>> In order
>> to use it inside Emacs, I add "C:/Program Files/Git/usr/bin" to `exec-path`
>> (it's not in my system path). Does that make sense?
>
> Yes: don't do that!  Git/usr/bin is a directory where MSYS2 programs
> used by Git are kept; you do NOT want them on your exec-path.

Gotcha. I've now added C:\Program Files\Git\cmd\bin to Path, though, because it
seems magit needs it. (That may be a bug, but that's a topic for another forum.)

I also switched to the MinGW Emacs from MSYS2, to make it easier to use other
MinGW tools from within Emacs.

Thanks for your help.

-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: How to *properly* set up Emacs on Windows?
  2022-02-09 13:19     ` Óscar Fuentes
@ 2022-02-10 21:58       ` Joost Kremers
  2022-02-10 22:37         ` Óscar Fuentes
  2022-02-11  7:00         ` Eli Zaretskii
  0 siblings, 2 replies; 14+ messages in thread
From: Joost Kremers @ 2022-02-10 21:58 UTC (permalink / raw)
  To: help-gnu-emacs


On Wed, Feb 09 2022, Óscar Fuentes wrote:
>> Will that give me a graphical Emacs or just a console one?
>
> A graphical one, of course.

Thanks. I made the switch now, everything seems to be working.

BTW, I asked this question because I was once bitten by this when I installed
Emacs on Linux using Homebrew. Turned out that Homebrew on Linux is a purely CLI
affair. (It's cool that Emacs can run on the console, but I do prefer the gooey version...)

>> (The
>> Windows binaries that were anounced on emacs-devel the other day
>> appear to be MSYS2 binaries?
>
> I don't think so.

I think I saw it mentioned somewhere that they were built with MSYS2. But I
understand now that it's possible to build MinGW binaries with MSYS2, so that
doesn't mean anything.

Thanks for your help, I have a much better idea of what I'm doing now.


-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: How to *properly* set up Emacs on Windows?
  2022-02-10 21:58       ` Joost Kremers
@ 2022-02-10 22:37         ` Óscar Fuentes
  2022-02-11  9:30           ` Joost
  2022-02-11  7:00         ` Eli Zaretskii
  1 sibling, 1 reply; 14+ messages in thread
From: Óscar Fuentes @ 2022-02-10 22:37 UTC (permalink / raw)
  To: help-gnu-emacs

Joost Kremers <joostkremers@fastmail.fm> writes:

>>> (The
>>> Windows binaries that were anounced on emacs-devel the other day
>>> appear to be MSYS2 binaries?
>>
>> I don't think so.
>
> I think I saw it mentioned somewhere that they were built with MSYS2. But I
> understand now that it's possible to build MinGW binaries with MSYS2, so that
> doesn't mean anything.

Correct. Actually, MSYS2 was created for building MinGW projects which
*build system* require a POSIX environment (autoconf, for instance). The
build products themselves do not depend on MSYS2 (unless you explicitly
use a toolchain that creates MSYS2 executables instead of the MinGW
toolchain, something only the MSYS2 maintainers usually do.)

> Gotcha. I've now added C:\Program Files\Git\cmd\bin to Path, though,
> because it seems magit needs it. (That may be a bug, but that's a
> topic for another forum.)

Magit will be fine without the directory of git.exe on PATH if you set
magit-git-executable to "C:/Program Files/Git/cmd/bin/git.exe"

> Thanks for your help, I have a much better idea of what I'm doing now.

You're welcome.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: How to *properly* set up Emacs on Windows?
  2022-02-10 21:58       ` Joost Kremers
  2022-02-10 22:37         ` Óscar Fuentes
@ 2022-02-11  7:00         ` Eli Zaretskii
  1 sibling, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2022-02-11  7:00 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Joost Kremers <joostkremers@fastmail.fm>
> Date: Thu, 10 Feb 2022 22:58:42 +0100
> 
> 
> >> (The
> >> Windows binaries that were anounced on emacs-devel the other day
> >> appear to be MSYS2 binaries?
> >
> > I don't think so.
> 
> I think I saw it mentioned somewhere that they were built with MSYS2. But I
> understand now that it's possible to build MinGW binaries with MSYS2, so that
> doesn't mean anything.

MSYS was originally developed to allow building MinGW programs using
Posix configury (Autoconf, Automake, a Posix shell, etc.).  So almost
every MinGW program that is a port from GNU or Unix is built using
MSYS.  But they are still MinGW (a.k.a. "native Windows") programs,
because they use MinGW GCC, MinGW Binutils, and MinGW header files and
libraries to compile and link the programs.  By contrast, building an
MSYS program requires to use MSYS GCC, header files and libraries, and
the produced executables and DLLs depend on MSYS DLL.

People use MSYS for purposes other than building MinGW programs,
because they want a Posix interactive environment, but I think that's
a mistake, because MSYS wasn't meant to serve as such an environment.
If one wants a Posix environment on Windows, one should install
Cygwin, IMO (and then use a Cygwin build of Emacs).



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: How to *properly* set up Emacs on Windows?
  2022-02-10 22:37         ` Óscar Fuentes
@ 2022-02-11  9:30           ` Joost
  0 siblings, 0 replies; 14+ messages in thread
From: Joost @ 2022-02-11  9:30 UTC (permalink / raw)
  To: fatiparty---

On Thu, 10 Feb 2022, at 23:37, Óscar Fuentes wrote:
> Magit will be fine without the directory of git.exe on PATH if you set
> magit-git-executable to "C:/Program Files/Git/cmd/bin/git.exe"

I tried setting that and it worked until I wanted to write a commit message. Then I got an error saying that git could not be found. That's probably something that should be fixed in magit or the `with-editor` package, though, so I intend to create an issue there.

-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-02-11  9:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-08 17:06 How to *properly* set up Emacs on Windows? Joost
2022-02-08 18:52 ` Eli Zaretskii
2022-02-09  8:14   ` Joost
2022-02-09 14:04     ` Eli Zaretskii
2022-02-10 21:05       ` Joost Kremers
2022-02-08 20:02 ` Óscar Fuentes
2022-02-09  8:48   ` Joost
2022-02-09 11:22     ` H. Dieter Wilhelm
2022-02-09 13:19     ` Óscar Fuentes
2022-02-10 21:58       ` Joost Kremers
2022-02-10 22:37         ` Óscar Fuentes
2022-02-11  9:30           ` Joost
2022-02-11  7:00         ` Eli Zaretskii
2022-02-09 12:28 ` Arash Esbati

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).