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.