From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#21687: Proposed patch to nt/runemacs.c: a way to augment environment variables prior to starting Em Date: Thu, 15 Oct 2015 18:30:19 +0300 Message-ID: <83twps87zo.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1444923236 2036 80.91.229.3 (15 Oct 2015 15:33:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 15 Oct 2015 15:33:56 +0000 (UTC) Cc: 21687@debbugs.gnu.org To: Evgeny Roubinchtein Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 15 17:33:45 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZmkXH-0005hL-Em for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Oct 2015 17:33:43 +0200 Original-Received: from localhost ([::1]:48117 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmkXG-0003M8-Ss for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Oct 2015 11:33:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmkUl-0008BW-I5 for bug-gnu-emacs@gnu.org; Thu, 15 Oct 2015 11:31:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZmkUh-0002Lv-GO for bug-gnu-emacs@gnu.org; Thu, 15 Oct 2015 11:31:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33559) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmkUh-0002Lp-Co for bug-gnu-emacs@gnu.org; Thu, 15 Oct 2015 11:31:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZmkUh-0002Px-1f for bug-gnu-emacs@gnu.org; Thu, 15 Oct 2015 11:31:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Oct 2015 15:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21687 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21687-submit@debbugs.gnu.org id=B21687.14449230259240 (code B ref 21687); Thu, 15 Oct 2015 15:31:02 +0000 Original-Received: (at 21687) by debbugs.gnu.org; 15 Oct 2015 15:30:25 +0000 Original-Received: from localhost ([127.0.0.1]:52500 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZmkU4-0002Oy-Jn for submit@debbugs.gnu.org; Thu, 15 Oct 2015 11:30:25 -0400 Original-Received: from mtaout25.012.net.il ([80.179.55.181]:52854) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZmkU1-0002Oj-FA for 21687@debbugs.gnu.org; Thu, 15 Oct 2015 11:30:23 -0400 Original-Received: from conversion-daemon.mtaout25.012.net.il by mtaout25.012.net.il (HyperSendmail v2007.08) id <0NW900700PGO9U00@mtaout25.012.net.il> for 21687@debbugs.gnu.org; Thu, 15 Oct 2015 18:27:54 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([84.94.185.246]) by mtaout25.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NW9002R8PMHO040@mtaout25.012.net.il>; Thu, 15 Oct 2015 18:27:54 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:107645 Archived-At: > Date: Wed, 14 Oct 2015 18:59:26 -0700 > From: Evgeny Roubinchtein > > My "use case" is that I compiled 64-bit Emacs under Windows following > instructions at > http://sourceforge.net/p/emacsbinw64/wiki/Build%20guideline%20for%20MSYS2-MinGW-w64%20system/, > but I want to avoid copying libraries from ${msys2_root}/mingw64/bin > to the Emacs installation directory, and I also don't want to add > ${msys2_root}/mingw64/bin to the PATH for my user account (let alone > system-wide). Can you explain why you don't want to do any of these 2 things? I'm not sure I understand the use case. Doing one or the other is the standard way of installing programs and their dependency libraries, and the former of the 2 is the platform recommended method, so it sounds strange that you don't want that. > The attached patch gives me a way to augment system environment > variables before runemacs starts the actual emacs executable. > With this patch applied, I can set the environment variable EMACS_ENV > to ">PATH>${msys2_root}/mingw64/bin", and have that directory appended > to the PATH but only in the environment of the runemacs process. That > environment is inherited by the emacs process, so I can allow Emacs to > find the libraries it needs in order to run without copying them to > the Emacs installation directory and without altering the PATH for my > user account. Thanks, but I think this solution will do more harm than help, even for you. Setting PATH of the Emacs process affects much more than just the places where Emacs looks for DLLs. It also affects where it will look for programs it invokes, such as Grep and Diff, that have nothing to do with optional libraries. Moreover, from the user perspective, runemacs.exe and emacs.exe are the same program, so having each one run with a different value of PATH will confuse and might even annoy. If you want to affect just the place where the DLLs are loaded from, you can instead redefine dynamic-library-alist (see w32-win.el for its default value) in your init files to include full absolute file names of each DLL; then Emacs will load only that DLL from its specified directory. I think this will solve your use case without affecting others. This solution can be used with the current Emacs code. If your use case is important enough, we could consider adding a facility that would allow the user to customize the directory or directories where Emacs looks for DLLs, using methods that don't affect PATH (e.g., the SetDllDirectory opr SetDefaultDllDirectories APIs). That'd be somewhat hairy, because we'd need to hook those into Posix-style environment variables like LD_LIBRARY_PATH, but it will be still cleaner than your suggestion. So please describe your use case in more detail for us to understand whether it needs any changes in existing code. Thanks.