From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#61637: 30.0.50; Fix Eglot tests that need HOME=~USER Date: Sat, 04 Mar 2023 11:48:27 +0000 Message-ID: <87v8jg68l0.fsf@gmail.com> References: <87ilfxv5dg.fsf@tcd.ie> <87h6vgelnn.fsf@tcd.ie> <83leksv6az.fsf@gnu.org> <87bkl972du.fsf@gmail.com> <83a60tarif.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22842"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: contovob@tcd.ie, 61637@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 04 12:47:19 2023 Return-path: Envelope-to: geb-bug-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 1pYQMA-0005iS-VI for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 Mar 2023 12:47:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pYQLx-00080c-6F; Sat, 04 Mar 2023 06:47:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYQLv-00080F-Ae for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2023 06:47:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pYQLu-0001jl-ON for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2023 06:47:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pYQLu-0000ta-CY for bug-gnu-emacs@gnu.org; Sat, 04 Mar 2023 06:47:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Mar 2023 11:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61637 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 61637-submit@debbugs.gnu.org id=B61637.16779304053419 (code B ref 61637); Sat, 04 Mar 2023 11:47:02 +0000 Original-Received: (at 61637) by debbugs.gnu.org; 4 Mar 2023 11:46:45 +0000 Original-Received: from localhost ([127.0.0.1]:35334 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYQLc-0000t4-9f for submit@debbugs.gnu.org; Sat, 04 Mar 2023 06:46:44 -0500 Original-Received: from mail-wm1-f50.google.com ([209.85.128.50]:51772) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYQLW-0000sm-Sf for 61637@debbugs.gnu.org; Sat, 04 Mar 2023 06:46:42 -0500 Original-Received: by mail-wm1-f50.google.com with SMTP id az36so3037557wmb.1 for <61637@debbugs.gnu.org>; Sat, 04 Mar 2023 03:46:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677930393; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bJAMnTtmdAbyZztuKYsoHq/GUUeFNOhqrKApvFthZvw=; b=d5mtRZnrM+6sldV0g1HcIU9H/tUHtdaNdyrMYescPpUSxyYPv2FXuOlm07TX8uDa/k 6W8rv7GtR/F7rv7zelN/5HFIfRRW5oB18T0cw11xy9ByCzbC62VeaoxBETCTwd+1XUm/ 4/d37y27RSJTLp54XtPRBAvZktnY1lMhtOvnn8ua5V87cIuWbi2gKebKSLcOsAWcv1dn iMF67UoT9LmGvJK4f4AMzxoxucMiKDCGuVvaFvfIc9q3tdfaVscIhaSxDn4+eyQtzyIk O7Qu+FDVziHzTPco3Vs1lgv2Eej8tEZopNVJsYbVjKfbCHoE1u0gozX140tO/mgLnBK2 wAmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677930393; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bJAMnTtmdAbyZztuKYsoHq/GUUeFNOhqrKApvFthZvw=; b=OcJASVpU8Cpu/X75cwNjMiU6xGUcSsaiu3cOFc4Dbzdf046jC3XCEkTSlhrEUUNe1W OClrQq9kXhBOOV1RuTPajAuYLRbB/iAZ7+clIDeD4pzyjXrNX+bvNcyK97BMxdQxApZU JwtylnFlFXiIQOR2tYaI2kZQVWZvG6uYao7mmqJk65qqnEZ6qmbF7XJ2rCgRCM8bnLWo UxyyEQIhVm6wlaklnK8+I01G2xM4l5g4U8dWrmYwrku/F0hp5Pok/kcD2OLG9ccy3WIf dTYMJa7YjrDiQU72PR5curhsj774izdjlCsMFNgkx/iXjzt4550G2/ownGJdqVPwEnWH RF/w== X-Gm-Message-State: AO0yUKWw4JP2rf79/GH9DuSlF30Ike2DNb3Gq4S0BV/+Qsz6YjIV0H58 tkJvEfCbO2/ROp9SLluKCaklTXDhQX4= X-Google-Smtp-Source: AK7set+FDnLzyD4Y1MPjH1rbAcS4nakqITuN0upY0AouqLLIiCQ04Wf4wpmnVh5q3kD/30nqSI1L5g== X-Received: by 2002:a05:600c:1907:b0:3dd:af7a:53db with SMTP id j7-20020a05600c190700b003ddaf7a53dbmr4298152wmq.11.1677930392628; Sat, 04 Mar 2023 03:46:32 -0800 (PST) Original-Received: from krug ([87.196.72.142]) by smtp.gmail.com with ESMTPSA id l8-20020a05600c4f0800b003b47b80cec3sm10064504wmq.42.2023.03.04.03.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Mar 2023 03:46:32 -0800 (PST) In-Reply-To: <83a60tarif.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 04 Mar 2023 09:46:00 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:257273 Archived-At: Eli Zaretskii writes: >> From: Jo=C3=A3o T=C3=A1vora >> Cc: "Basil L. Contovounesios" , 61637@debbugs.gnu.org >> Date: Sat, 04 Mar 2023 01:04:45 +0000 >>=20 >> I installed some language servers like clangd, rust-analyzer and pylsp, >> and they need to a valid HOME to be able to function. > > Please tell more about this: what exactly do these servers need from > the home directory? Every server is different. This is the complain for a pylsp installed with 'pip install pylsp' for the regular user, which you can find in the output of e.g. make -C test lisp/progmodes/eglot-tests SELECTOR=3D'"basic-completions"' This are the relevant parts of the output. Here, it looks like the pylsp trampoline in ~/.local/bin/pylsp can't find the main supporing library, which probably lives around the corner in ~/.local/lib/python3.10/site-packages. [stderr] PWD: /tmp/eglot--fixturelfcOUE/project [stderr] XDG_CONFIG_HOME: /dev/null [stderr] HOME: /tmp/ .... [stderr] EMACS_TEST_DIRECTORY: /home/capitaomorte/Source/Emacs/emacs/test [stderr] Traceback (most recent call last): [stderr] File "/home/capitaomorte/.local/bin/pylsp", line 14, in [stderr] from pylsp.__main__ import main [stderr] ModuleNotFoundError: No module named 'pylsp' [internal] Sat Mar 4 11:31:48 2023: (:message "Connection state changed" :change "exited abnormally with cod= e 1\n") =20=20=20=20 ----------b---y---e---b---y---e---------- [eglot] Killing (something.py), wiping /tmp/eglot--fixturelfcOUE, restor= ing nil Test eglot-test-basic-completions backtrace: signal(error ("[eglot] -1: Server died")) I suppose basil found something similar for rust-analyzer, though my installation of it is system-wide, so I don't get that particular problem. >> This is acceptable for Eglot devs like me, but other devs that don't >> know about this variable will still be confused. WDYT? > > As I said, I don't like the idea of using the user's real home > directory for test purposes. We could end up clobbering precious > files there. We could also have tests fail because some user setting > in the home directory makes the test results unpredictable. As I understand it, the concern of cloberring user customizations is mostly related to Emacs' own packages like ido or auto-save-mode, some of them do write files in ~/.emacs.d and similar. That is reasonable. But this is different IMO. We're talking about user-installed language servers, which presumably these users are already using (because they installed them). Only for the specific invocations of these servers is HOME spoofed. Overall I think the risk is low. Eglot has had these types of tests since practically the beginning and I've never had complains of clobbered files. >> > Why not do this the other way around: trick Eglot to think the home >> > directory doesn't exist (as I understand it already knows how to >> > handle this)? >>=20 >> I don't understand what you mean: this is entirely constrained to how >> certain language servers work, so eglot.el itself can't handle it. > > In the original report, Basil sais: > >> The main problem is that: >> 0. test/Makefile.in sets HOME=3D/nonexistent >> 1. lisp/emacs-lisp/ert-x.el sets HOME=3D/tmp :( >> 2. eglot--call-with-fixture tries to detect when HOME is nonexistent, >> but /tmp exists, so that's left unchanged >> 3. The Rust tools look under HOME=3D/tmp for which toolchain to use, but >> the answer is under ~USER, so they give up > > I interpreted item 2 as meaning that eglot--call-with-fixture can cope > with the situation where the user's home directory doesn't exist Ah, I understand. Indeed it could "cope", but only by doing exactly the same kind of spoof (or rather, unspoof) that Basil was proposing. But at a certain point in Emacs-29 that unspoof stopped working. In fact, I missed this in Basil's patch, but I think the correct fix is actually to fix eglot--call-with-fixture directly, with Basil's better technique of re-constructing $HOME. diff --git a/test/lisp/progmodes/eglot-tests.el b/test/lisp/progmodes/eglot= -tests.el index 5d5de59a19a..5f5adc8e5b3 100644 --- a/test/lisp/progmodes/eglot-tests.el +++ b/test/lisp/progmodes/eglot-tests.el @@ -103,22 +103,21 @@ eglot--call-with-fixture (set (car spec) (cadr spec))) ((stringp (car spec)) (push spec file-specs)))) (unwind-protect - (let* ((home (getenv "HOME")) - (process-environment + (let* ((process-environment (append `(;; Set XDF_CONFIG_HOME to /dev/null to prevent - ;; user-configuration to have an influence on + ;; user's configuration to have an influence on ;; language servers. (See github#441) "XDG_CONFIG_HOME=3D/dev/null" ;; ... on the flip-side, a similar technique by ;; Emacs's test makefiles means that HOME is set to - ;; /nonexistent. This breaks some common - ;; installations for LSP servers like pylsp, making - ;; these tests mostly useless, so we hack around it - ;; here with a great big hack. - ,(format "HOME=3D%s" - (if (file-exists-p home) home - (format "/home/%s" (getenv "USER"))))) + ;; /nonexistent or /tmp/. This breaks some common + ;; installations for LSP servers like pylsp, and + ;; rust-analyzer, making these tests mostly + ;; useless, so we hack around it here with a great + ;; big hack. + ,(format "HOME=3D%s" (expand-file-name (concat + "~" (user-login-n= ame))))) process-environment)) ;; Prevent "Can't guess python-indent-offset ..." messages. (python-indent-guess-indent-offset-verbose . nil)