emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating and accessing environmental variables


From: the_wurfkreuz
Subject: Re: Creating and accessing environmental variables
Date: Sun, 08 Dec 2024 20:33:51 +0000

Yes, only after using addpath was eshell/which able to find executables in the added paths.
On Sunday, December 8th, 2024 at 23:23, Ship Mints <shipmints@gmail.com> wrote:
Triple coffee... I don't use eshell much, so need to add that you may want to use "addpath" in an eshell instance which you can verify running eshell-get-path in eshell.

On Sun, Dec 8, 2024 at 3:14 PM Ship Mints <shipmints@gmail.com> wrote:
Sheesh, I need more coffee... More like this since it's an OS path:

(concat "/tmp/foo/bar" path-separator (getenv "PATH"))

On Sun, Dec 8, 2024 at 2:51 PM Ship Mints <shipmints@gmail.com> wrote:
Couple of things. First, you should not be concatenating paths like you showed. Do the following instead and it will be cross platform and more "correct":

(file-name-concat "/tmp/foo/bar" (getenv "PATH"))

Second, a question. After you setenv your PATH, in eshell, what does "echo $PATH" show?

On Sun, Dec 8, 2024 at 1:51 PM the_wurfkreuz via Emacs development discussions. <emacs-devel@gnu.org> wrote:
Is it possible to set environment variables and access them immediately without reloading the Emacs configuration (like using the load-file function)?

For instance, when I evaluate this code to set the PATH variable:

(let ((paths '("/some/path"
"/some/path/2")))
;; (setq exec-path (append paths exec-path))
(setenv "PATH" (concat (string-join paths ":")
":"
(getenv "PATH"))))

And then try to launch eshell in the current Emacs session, I find that the new values aren't appended. The only way to set them is to put the code into a config file and reload it through (load-file "~/.emacs.d/init.el").


reply via email to

[Prev in Thread] Current Thread [Next in Thread]