From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ship Mints Newsgroups: gmane.emacs.devel Subject: Re: Creating and accessing environmental variables Date: Sun, 8 Dec 2024 15:23:40 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000032c05c0628c8084d" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6034"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "emacs-devel@gnu.org" To: the_wurfkreuz Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Dec 08 21:25:31 2024 Return-path: Envelope-to: ged-emacs-devel@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 1tKNqM-0001NF-4D for ged-emacs-devel@m.gmane-mx.org; Sun, 08 Dec 2024 21:25:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tKNpF-0004Xe-Cg; Sun, 08 Dec 2024 15:24:21 -0500 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 1tKNpD-0004OA-Ee for emacs-devel@gnu.org; Sun, 08 Dec 2024 15:24:19 -0500 Original-Received: from mail-vk1-xa2d.google.com ([2607:f8b0:4864:20::a2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tKNpB-0008He-RA for emacs-devel@gnu.org; Sun, 08 Dec 2024 15:24:19 -0500 Original-Received: by mail-vk1-xa2d.google.com with SMTP id 71dfb90a1353d-51623968932so305293e0c.1 for ; Sun, 08 Dec 2024 12:24:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733689456; x=1734294256; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=IA6DYu2Qm6RKBKukhdTQi/2WlaqEbJhwRDy6lLWyPXM=; b=KRa0qjQkRutEJj6/VT8hS8tqfB2RYBtwzav5xeHyYPhx0yqSZcUsM3gXoMiZ6yzn9d FZ01fYFK4ld+GlraS4YF8SSO4oUpNEu4y8sygBfh1X/S+BVR1KiijKhJi0kuexL+3p0f yXcOxx/Ff1U8ycRhToq0pbmR3hjmpTUoLlLgtCQCabtkvx/XD9Xyp2hp0IwVFC/BC5Qh NK18X3l4+SwDsvmf4EWySnl7Ys/7BXcXIrq1Wi75GvaVa4Xm72E5PGpOSq2/I0MKQQry epV1vcQP3zwIBw0LIhbW7CEP7yJN2z/w0faCBFpt0RVst2v8nb0OZJe/iNGbXu78fpAP W8OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733689456; x=1734294256; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IA6DYu2Qm6RKBKukhdTQi/2WlaqEbJhwRDy6lLWyPXM=; b=hQV/eIEsUjCsb7+hnGu0roDIUdb8YNA7kk1uD6zFarO/m4LsoXWSkG1N+iC2W481Fq /drXxVHquiZlrX3tIhiuX3xuGdGoELnkNSIbBNnEo+FfwaKiv0a+Iuoq9bsToKjoCJp1 zymoxefPVbD4W2ehttWNNo0sUYqTjJPideOiTR+hmb4dZaPZrXE03bzBSsZv2ECpAKNW U4cz6KkDM/SVaVCtTHdXYFPzVrN/5dh/m5aBqbUtxrWt8pNFz5a+RohbAzvJdXwvivNY NeJpsY4S4t0Fw73bSHYTr27Lrzl2pM4hruWhRvaHoJNAV6s2gO8MpfBLG/ziTqVsiRda YElg== X-Gm-Message-State: AOJu0YyMH8zArzVluKDHfuJ+Hxcko2SWNnfq7GiCnjSvkcAlXxBqxy6f aU3n5KyrM2PiXPFEASpHwWCVvTJhD2DKR5RLy4NWsGvbXYwNoF/XXebIB8fcay9EuRD85WkfVpW v+F3VmdDBu/7kDk2DbLw+uAJiDKM= X-Gm-Gg: ASbGncsAxeEO/dCFSY7muIMuswadP3R/B/BxrQBPlIJQgtIXNhbICK6uJ5ZJKXSNW+/ S6ls96o+GAquMOdB29sNlzTD4gWZga+I= X-Google-Smtp-Source: AGHT+IGtAcJ5eDiYq5T1eKcRM9+hztqHChv6NK5w/U/KrGgEDVwqyoCmnYNzCLyhiLHD4UoAHxa6RTHbmKLcVNSJAWI= X-Received: by 2002:a05:6122:8b08:b0:50d:3ec1:1534 with SMTP id 71dfb90a1353d-515fcae9e39mr8481707e0c.7.1733689456374; Sun, 08 Dec 2024 12:24:16 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::a2d; envelope-from=shipmints@gmail.com; helo=mail-vk1-xa2d.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, HTML_MESSAGE=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: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:326214 Archived-At: --00000000000032c05c0628c8084d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=E2=80=AFPM Ship Mints wro= te: > 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=E2=80=AFPM Ship Mints w= rote: > >> 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=E2=80=AFPM the_wurfkreuz via Emacs developme= nt >> discussions. 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= "). >>> >> --00000000000032c05c0628c8084d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Triple coffee... I don't use eshell much, so need to add that you ma= y want to use "addpath" in an eshell=C2=A0instance which you can = verify running eshell-get-path=C2=A0in eshell.

O= n Sun, Dec 8, 2024 at 3:14=E2=80=AFPM Ship Mints <shipmints@gmail.com> wrote:
Sheesh, I need more coffee... More l= ike this since it's an OS path:

=C2=A0 (concat "/tmp/foo/bar" path-separat= or (getenv "PATH"))

On Sun, Dec 8, 2024 at 2:51=E2=80=AFPM S= hip Mints <ship= mints@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 platfo= rm and more "correct":

=C2=A0 (file-name-concat "/tmp/foo/bar" (gete= nv "PATH"))

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

<= div dir=3D"ltr" class=3D"gmail_attr">On Sun, Dec 8, 2024 at 1:51=E2=80=AFPM= the_wurfkreuz via Emacs development discussions. <emacs-devel@gnu.org> wrote:
<= /div>
Is it possible to= set environment variables and access them immediately without reloading th= e Emacs configuration (like using the load-file function)?

<= /div>For instance, when I evaluate this code to set the PATH variable= :

(let ((paths '("/some/path"
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "/some/path/2&q= uot;)))
=C2=A0 ;; (setq exec-path (append paths exec= -path))
=C2=A0 (setenv "PATH" (concat (str= ing-join paths ":")
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ":"= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (getenv "PATH"))))
<= /div>
And then try to launch eshell in the current Em= acs session, I find that the new values aren't appended. The only way t= o set them is to put the code into a config file and reload it through (loa= d-file "~/.emacs.d/init.el").
--00000000000032c05c0628c8084d--