From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#50607: 28.0.50; 'M-x compile' misbehaves if 'process-environment' is buffer-local Date: Wed, 15 Sep 2021 20:08:07 +0200 Message-ID: <87h7el4sqg.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17810"; mail-complaints-to="usenet@ciao.gmane.io" To: 50607@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 15 20:12:33 2021 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 1mQZOb-0004P7-BU for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 15 Sep 2021 20:12:33 +0200 Original-Received: from localhost ([::1]:39938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQZOZ-0008Fg-3m for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 15 Sep 2021 14:12:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQZLD-00039z-3v for bug-gnu-emacs@gnu.org; Wed, 15 Sep 2021 14:09:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41641) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mQZLC-0001xT-P8 for bug-gnu-emacs@gnu.org; Wed, 15 Sep 2021 14:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mQZLC-0005y1-Co for bug-gnu-emacs@gnu.org; Wed, 15 Sep 2021 14:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Sep 2021 18:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50607 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163172929822875 (code B ref -1); Wed, 15 Sep 2021 18:09:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Sep 2021 18:08:18 +0000 Original-Received: from localhost ([127.0.0.1]:53187 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQZKU-0005wt-H1 for submit@debbugs.gnu.org; Wed, 15 Sep 2021 14:08:18 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:34298) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQZKQ-0005wi-16 for submit@debbugs.gnu.org; Wed, 15 Sep 2021 14:08:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQZKP-0001ur-S8 for bug-gnu-emacs@gnu.org; Wed, 15 Sep 2021 14:08:13 -0400 Original-Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:46022) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mQZKO-0001I8-34 for bug-gnu-emacs@gnu.org; Wed, 15 Sep 2021 14:08:13 -0400 Original-Received: by mail-wm1-x32e.google.com with SMTP id j17-20020a05600c1c1100b002e754875260so2661478wms.4 for ; Wed, 15 Sep 2021 11:08:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version; bh=/8Ie6moEuQGZrGdPXK4jXttX+pFQycrtan92ZXT4s8s=; b=e7QvKLAmgwpEJy6DlkX84o/MCpsXCd86xCCkNgowVIl0KF8S2MPooIOgmHTDuypc+G n+D0rvDGaN5jbtyrXzr1SXuI9sehmXuZOORudU402T5BKi+1wpK1ycDbzrE6HTke4w/z kAN2LnnPw0SjrZlY04Ztc4p5oryaw460XYeSdbx6gD686R5UtPMmAx4rYR1nCOmUButl QpZtRPa9eYHWnoa7qBL+SruVsGiR2pPU4Q1LIW5gKTLgO/OuiUKTtMx5mRb3qOm846kZ WhcXsCjK+lvvvBDTctFgLdXYnKviodS0prTXCiQOxXcoa69vwN3iPWvlnr5qbRDTaoUM 5L0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=/8Ie6moEuQGZrGdPXK4jXttX+pFQycrtan92ZXT4s8s=; b=XK+0+klSbJGIPQF1ARnUcbJQQNU2281+Tzcw1kEjVbudRTD684NHHkIsjAvgp4VL+D GpV+6hMvK29aSinEptUSeG3riLKLxRS0DSIaoUztXLzp/7U1HR2UECb374jb1CMKrW5H vCGgIT8/iBiz41Qu1UFMT6vb/UNnMnF6MB5HL8QM7SGEs+yX+VMrnnsGHuqf1dBz/Vzr oiCG+WoUCdS1T0THcFQ2ngQpJtIh1JUqa4Wup/RFuKg0iZoTpo+2Wtt67hEvJFXTOV0t BliR/8wBatPgi2/ut2mKotUiDkP67VjR60xdzLWMTKr06Ws7u2JstyFA/UTEGXBOe9tb u4Mg== X-Gm-Message-State: AOAM533NjExxI/QOAoDB/ezwU/JnkmPV8mwYdjj9UAzop5M4F6oVGUBX sNo89/poaEOiJj8wHxIDoAMLP0hCjyc= X-Google-Smtp-Source: ABdhPJxgLSe3WhWM/t8RPTtUbTWAky/3DdnqLH2lGM7g8xTAcWYeDb6AOhI3XleS5D//toUgZ++G6w== X-Received: by 2002:a05:600c:3203:: with SMTP id r3mr5868478wmp.175.1631729289809; Wed, 15 Sep 2021 11:08:09 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::3c3e]) by smtp.gmail.com with ESMTPSA id e2sm737541wra.40.2021.09.15.11.08.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Sep 2021 11:08:09 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=arstoffel@gmail.com; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.bugs:214422 Archived-At: --=-=-= Content-Type: text/plain This has already been discussed on email-devel but didn't come to a conclusion. I don't want to linger on it, but I would like the problem to get assigned a bug number, so it has a chance of being addressed in the future. A summary of the problem: suppose buffer A has a buffer-local value of 'process-environment' containing an extra directory in the PATH, and that a given 'program' is only available on that directory. Then 'M-x compile RET program RET' will not find 'program', because the *compilation* buffer will not "inherit" the PATH from A. For the reasons why one would want/need such a setup, see https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg01380.html and other messages in that thread. Finally, I attach my proposed patch. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Make-compile-respect-buffer-local-process-environmen.patch >From a104e1eae100f01585587df30f49866f3b038785 Mon Sep 17 00:00:00 2001 From: Augusto Stoffel Date: Thu, 29 Apr 2021 12:45:04 +0200 Subject: [PATCH] Make 'compile' respect buffer-local process environment * lisp/progmodes/compile.el (compilation-start): Use `process-environment' from original buffer in the compilation process. --- lisp/progmodes/compile.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index af7b8292b7..bdf20a3f51 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -1783,6 +1783,8 @@ compilation-start (replace-regexp-in-string "-mode\\'" "" (symbol-name mode)))) (thisdir default-directory) (thisenv compilation-environment) + (bufferpath (when (local-variable-p 'exec-path) exec-path)) + (bufferenv (when (local-variable-p 'process-environment) process-environment)) outwin outbuf) (with-current-buffer (setq outbuf @@ -1850,6 +1852,12 @@ compilation-start ;; NB: must be done after (funcall mode) as that resets local variables (setq-local compilation-directory thisdir) (setq-local compilation-environment thisenv) + (if bufferpath + (setq-local exec-path bufferpath) + (kill-local-variable 'exec-path)) + (if bufferenv + (setq-local process-environment bufferenv) + (kill-local-variable 'process-environment)) (if highlight-regexp (setq-local compilation-highlight-regexp highlight-regexp)) (if (or compilation-auto-jump-to-first-error -- 2.31.1 --=-=-=--