help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to *properly* set up Emacs on Windows?


From: Eli Zaretskii
Subject: Re: How to *properly* set up Emacs on Windows?
Date: Tue, 08 Feb 2022 20:52:03 +0200

> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]