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.bugs Subject: bug#72849: [PATCH] Keep project's exec-path during with-temp-buffer call Date: Thu, 29 Aug 2024 19:25:49 +0300 Message-ID: <864j73fg8i.fsf@gnu.org> References: <87v7zlo8yy.fsf@lipklim.org> <86y14ghmm1.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7707"; mail-complaints-to="usenet@ciao.gmane.io" Cc: eugene.dev@lipklim.org, 72849@debbugs.gnu.org To: kobarity Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 29 18:26:20 2024 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 1sjhyU-0001qB-W1 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 29 Aug 2024 18:26:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjhyP-0004kk-JV; Thu, 29 Aug 2024 12:26:13 -0400 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 1sjhyK-0004jU-6A for bug-gnu-emacs@gnu.org; Thu, 29 Aug 2024 12:26:08 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sjhyJ-0006GR-QE for bug-gnu-emacs@gnu.org; Thu, 29 Aug 2024 12:26:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=JcXAcMBpjqO2K1/MGQhqJkGEAn50z4bu6a1qmSiZrWQ=; b=rI3OFdLsgsKNg6jMyA2UUhMGCG6zEISmSUnMeEekyYaKOaH2PvahjwA0tvjCweyuEdFi7VD0ZyEiX0HA7NClS95gBp7GD+zmxMlBhX5onW5ByQoREgwl1FykuVDUvvxgXLrb3HYmm6aVVfC7dIR1dHGToi+4rslpfhyERu3b0c03GJSEKACqdKf+bJfT17/Jo0orrmDdZtSeEPMLdf1bvQ2WLjas5ZvE2fGid0ShgefQDWjrvXZ3t+DYlcWincAHXUkImLsL3vQpHRtXNybmCdtVVM8uF8ik4FPJElO4SnrqYPgJYDOLwOE/Xx+rxdTgsXSqMnIyQp2KUgNHr47EPA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sjhzB-0005Bx-Vy for bug-gnu-emacs@gnu.org; Thu, 29 Aug 2024 12:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 29 Aug 2024 16:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72849 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 72849-submit@debbugs.gnu.org id=B72849.172494881719934 (code B ref 72849); Thu, 29 Aug 2024 16:27:01 +0000 Original-Received: (at 72849) by debbugs.gnu.org; 29 Aug 2024 16:26:57 +0000 Original-Received: from localhost ([127.0.0.1]:52047 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sjhz6-0005BS-Qy for submit@debbugs.gnu.org; Thu, 29 Aug 2024 12:26:57 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:45100) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sjhz3-0005B8-39 for 72849@debbugs.gnu.org; Thu, 29 Aug 2024 12:26:55 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sjhy3-0006Et-DN; Thu, 29 Aug 2024 12:25:51 -0400 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=JcXAcMBpjqO2K1/MGQhqJkGEAn50z4bu6a1qmSiZrWQ=; b=hefP1iUxm5gw U41PeO5jkNA8vEoXqsRmRGgn76WPz0x49g0n9piakoTKnS3TVJyWRKQBDSac42J2ciNT6rFqNUfwC 800XVkT8juG2odFvei5xvHD0OZa9r4v4L+wXobyh7vOVlBCsNSWrjpYx5SKWDehQvMZGkGZdVBTVm i3AVeGfSX9Aapdzw3rSdR2GEaCCjqndSLLNNnPX9yG3bZqOxmXzlaOdAZiUTbzpx1cB/RrhlF+pgz ayiJbqjSmPJ1k3pr/72K0s2ci81EXIABDZyE9J/cdIQfUPIM8Ij0l9pAkCU1CuMXCFyzvDv3MKIAF YrzEi0d0+3Zk6H72jxdUfw==; In-Reply-To: (message from kobarity on Fri, 30 Aug 2024 01:08:25 +0900) 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:290940 Archived-At: > Date: Fri, 30 Aug 2024 01:08:25 +0900 > From: kobarity > Cc: 72849@debbugs.gnu.org > > Eli Zaretskii wrote: > > > Date: Wed, 28 Aug 2024 00:13:25 +0100 > > > From: Evgenii Klimov via "Bug reports for GNU Emacs, > > > the Swiss army knife of text editors" > > > > > > `with-temp-buffer' doesn't respect buffer-local environment variables, > > > `exec-path' in this case. Which results in executables not being found, > > > or the wrong versions of executables being picked up. E.g. if > > > environment variable is modified via .dir-local file or direnv/envrc > > > package. > > > > Hmm, this doesn't look clean to me: exec-path is just one variable, > > what makes it special here? > > > > Moreover, it sounds like python-shell-with-environment, which > > python-shell-prompt-detect calls, already attempts to have > > buffer-local value of exec-path to be available to Python, so why > > isn't that working for you? And if it isn't work, I think we should > > amend python-shell-with-environment to do this, so we don't need to do > > it "by hand". > > > > kobarity, any comments or suggestions? > > The problem is that `with-temp-buffer' creates a new buffer, so the > buffer local value of `exec-path' is not maintained in the new buffer. > It is used to find the Python interpreter unless the interpreter is > specified using the absolute path. > > I think Evgenii's patch is logically correct, but it would be better > to create a modified version of `with-temp-buffer' which keeps > `exec-path' in the new buffer. The attached is my proposal to do so. Thanks, but what about python-shell-with-environment: doesn't it already try to do this, including preserving exec-path from the original buffer?