unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Jim Porter <jporterbugs@gmail.com>
Cc: coltonlewis@google.com, 57556@debbugs.gnu.org
Subject: bug#57556: 28.1; Eshell not finding executables in PATH when tramp-integration loaded
Date: Sun, 02 Oct 2022 10:48:58 +0200	[thread overview]
Message-ID: <87wn9iehl1.fsf@gmx.de> (raw)
In-Reply-To: <2d1f17a5-554d-1b1f-7bcb-52e3839d9d0c@gmail.com> (Jim Porter's message of "Sat, 1 Oct 2022 22:34:50 -0700")

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

> On 10/1/2022 3:02 PM, Jim Porter wrote:
>> On 10/1/2022 1:25 PM, Michael Albinus wrote:
>>> Again, no possibility to use connection-local variables? You use them
>>> already by calling (path-separator) ...
>> I'll take a look at doing that. As I understand it, connection-local
>> variables are cleared if the associated connection gets cleaned up,
>> right? I wonder if that would be the right thing to do. For example,
>> if I cd into a remote host in Eshell, then update Eshell's $PATH for
>> that host, then clean up the connection, should the $PATH be reset
>> to the default for that host? I'm really not sure...
>
> After a bit of trying, I wasn't able to get this to work. I was doing
> something along these lines:
>
>   (defvar-local eshell-path-env-list nil)
>
>   (connection-local-set-profile-variables
>    'eshell-connection-local-profile
>    '((eshell-path-env-list . nil)))
>
>   (connection-local-set-profiles
>    nil 'eshell-connection-local-profile)
>
>   ;; When getting the $PATH...
>   (with-connection-local-variables
>    (or eshell-path-env-list
>        (setq eshell-path-env-list (butlast (exec-path)))))
>
> However, the next time I try to get the $PATH in the
> 'with-connection-local-variables' block, the value is nil again, so it
> gets recomputed. I guess 'setq' inside
> 'with-connection-local-variables' doesn't work?

Yes. with-connection-local-variables is designed to provide those
variables inside the BODY only. And you have used nil as CRITERIA in
connection-local-set-profiles, which means you get the same variables
for every kind of default-directory, which means you don't use
connection-local variables at all :-)

What you need is a permanent setting of variables. Something like

(connection-local-set-profiles
 (connection-local-criteria-for-default-directory 'eshell)
 'eshell-connection-local-profile)

(let ((enable-connection-local-variables t)
      connection-local-variables-alist) ;; I'm not sure this is needed.
  (hack-connection-local-variables-apply
   (connection-local-criteria-for-default-directory 'eshell))
  ;; The body.
  ...)

I have used `eshell' as APPLICATION, the default application would be
`tramp'. But since you care only your eshell-* variables, you could use
an own namespace I believe. Of course, you could also use `tramp' or
anything else, it's your decision.

> This is also made more complex by the fact that in an Eshell
> subcommand, we want to be able to modify the $PATH locally so that
> it's reset to the previous value after the subcommand.

In this case, you could use the with-connection-local-variables macro
indeed. Something like

(let ((connection-local-default-application 'eshell))
  (with-connection-local-variables
  ;; Some temprary modifications.
  ...)

> Since there are so many different things that can alter the $PATH
> value, making it connection-local seemed to be more complex in my
> experiments. The alist implementation is a bit more primitive, but I
> found it easier to reason through the logic. That could just be
> because I don't quite understand all the details of connection-local
> variables though.

It is more complex to set it up, indeed. (I wish we would have made it
more friendly.) But in the long term, it will be more robust I believe.

Best regards, Michael.





  reply	other threads:[~2022-10-02  8:48 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-03  5:03 bug#57556: 28.1; Eshell not finding executables in PATH when tramp-integration loaded Colton Lewis via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-03 12:26 ` Lars Ingebrigtsen
2022-09-18 11:18 ` Michael Albinus
2022-09-18 18:54   ` Jim Porter
2022-09-18 19:07     ` Michael Albinus
2022-09-22 17:23       ` Colton Lewis via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-22 17:55         ` Michael Albinus
2022-09-30  3:54           ` Jim Porter
2022-10-01 20:25             ` Michael Albinus
2022-10-01 22:02               ` Jim Porter
2022-10-02  5:34                 ` Jim Porter
2022-10-02  8:48                   ` Michael Albinus [this message]
2022-10-07  3:19                     ` Jim Porter
2022-10-07 18:28                       ` Michael Albinus
2022-10-08 22:09                         ` Jim Porter
2022-10-09 18:01                           ` Michael Albinus
2022-10-13  4:11                             ` Jim Porter
2022-10-13  6:35                               ` Eli Zaretskii
2022-10-14  1:29                                 ` Jim Porter
2022-10-14  6:17                                   ` Eli Zaretskii
2022-10-14 12:28                                   ` Michael Albinus
2022-10-14 12:27                               ` Michael Albinus
2022-10-14 20:53                                 ` Jim Porter
2022-10-15 10:38                                   ` Michael Albinus
2022-10-15 23:33                                     ` Jim Porter
2022-10-16 17:00                                       ` Michael Albinus
2022-10-16 23:01                                         ` Jim Porter
2022-10-16 20:51                                   ` Richard Stallman
2022-10-16 23:07                                     ` Jim Porter
2022-10-18  1:51                                       ` Jim Porter
2022-10-10  9:15                           ` Michael Albinus
2022-10-02  8:55                 ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wn9iehl1.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=57556@debbugs.gnu.org \
    --cc=coltonlewis@google.com \
    --cc=jporterbugs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).