From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: How to *properly* set up Emacs on Windows? Date: Tue, 08 Feb 2022 20:52:03 +0200 Message-ID: <838rulw5rg.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4063"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 08 21:08:32 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nHWmu-0000w0-Ce for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 08 Feb 2022 21:08:32 +0100 Original-Received: from localhost ([::1]:54270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHWmt-0000KA-1m for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 08 Feb 2022 15:08:31 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:50250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHVb4-0007IP-KC for help-gnu-emacs@gnu.org; Tue, 08 Feb 2022 13:52:14 -0500 Original-Received: from [2001:470:142:3::e] (port=38026 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHVb4-0002Yg-8n for help-gnu-emacs@gnu.org; Tue, 08 Feb 2022 13:52:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=zKP05K9w76yUYEajNgOlm9SpENsRVwJ19oqJkY/zWN8=; b=rG2lqLtDgefJ IIRVeC7yVnEKNEC+IPricqN5M6e/gkXbY86yowFliK6tZvU36hi9ABw8mCqcMpd66caRAd2O6i1He 9AKUA+kCCoz9XEt39LXNYuqnxT0s3mxeQ5Ed7awVPIbgrUso59ftY5LDthLLREdlToos0AsvQUdA0 5RVA4JtQGrd3GFv019QTJoft0w8d/2vHPOSEI9TavJFe02BI2v7TtPUTq4/XBFEimXi7NJvqbfKmB 4uMFPnlPd7QznRK/3kb3HlRRaMqIdRSkhwt2A2e0AFj9wS97SYLk9tPQVQnSY+wO/Do2qxDnUlmOd VukilrS/CQpJmk0vHuksfQ==; Original-Received: from [87.69.77.57] (port=3713 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHVb3-00020N-MV for help-gnu-emacs@gnu.org; Tue, 08 Feb 2022 13:52:14 -0500 In-Reply-To: (message from Joost on Tue, 08 Feb 2022 18:06:36 +0100) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:135846 Archived-At: > Date: Tue, 08 Feb 2022 18:06:36 +0100 > From: Joost > > 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.