unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Set the HOME environment variable in Emacs package debug script instead of using it on command line.
@ 2021-10-26  2:01 Hongyi Zhao
  2021-10-26  5:04 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 10+ messages in thread
From: Hongyi Zhao @ 2021-10-26  2:01 UTC (permalink / raw)
  To: help-gnu-emacs

I've writtent the following Emacs package debug script which can be
run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:

```emacs-lisp
#!/usr/bin/env bash
:;# $ realpath init.el
:;# /home/werner/.emacs.d/debug/.emacs.d/init.el
:; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5
/usr/local/bin/emacs -- "$@"; exit

;;Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el"
user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)

(use-package company
  :demand t
  :hook
  (after-init . global-company-mode))
```
I want to set the HOME environment variable in the lisp code, so it
will not disturb the system environment variable settings.

Any tips for achieving this goal?

Regards,
HZ



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Set the HOME environment variable in Emacs package debug script instead of using it on command line.
  2021-10-26  2:01 Set the HOME environment variable in Emacs package debug script instead of using it on command line Hongyi Zhao
@ 2021-10-26  5:04 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-26  9:57   ` Hongyi Zhao
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-26  5:04 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> I want to set the HOME environment variable in the lisp
> code, so it will not disturb the system environment
> variable settings.

Don't understand (don't want to :)) but there is `setenv' FYI.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Set the HOME environment variable in Emacs package debug script instead of using it on command line.
  2021-10-26  5:04 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-26  9:57   ` Hongyi Zhao
  2021-10-26 11:25     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 10+ messages in thread
From: Hongyi Zhao @ 2021-10-26  9:57 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Tue, Oct 26, 2021 at 1:05 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > I want to set the HOME environment variable in the lisp
> > code, so it will not disturb the system environment
> > variable settings.
>
> Don't understand (don't want to :)) but there is `setenv' FYI.

I've set the new HOME with the following method, but it doesn't get
the same testing result as reported here [1]:

#!/usr/bin/env bash
:; env myhome=$(dirname $(dirname $(realpath -e $0)))
proxychains-ng-socks5 /usr/local/bin/emacs -Q --load $(realpath -e $0)
-- "$@"; exit

(setenv "HOME" (substitute-in-file-name "${myhome}"))
;;Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el"
user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)


(use-package company
  :demand t
  :hook
  (after-init . global-company-mode))


[1] https://github.com/company-mode/company-mode/discussions/1248#discussioncomment-1535692



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Set the HOME environment variable in Emacs package debug script instead of using it on command line.
  2021-10-26  9:57   ` Hongyi Zhao
@ 2021-10-26 11:25     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-26 12:37       ` Hongyi Zhao
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-26 11:25 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> I've set the new HOME with the following method, but it
> doesn't get the same testing result

Please make a much simpler example that only does this and
nothing else ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Set the HOME environment variable in Emacs package debug script instead of using it on command line.
  2021-10-26 11:25     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-26 12:37       ` Hongyi Zhao
  2021-10-26 12:49         ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 10+ messages in thread
From: Hongyi Zhao @ 2021-10-26 12:37 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Tue, Oct 26, 2021 at 7:30 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > I've set the new HOME with the following method, but it
> > doesn't get the same testing result
>
> Please make a much simpler example that only does this and
> nothing else ...

I don't think that a simple example can represent the problem
discussed in the GitHub issue. In one word, my question can be
expressed as follows: Set the HOME environment variable in shell and
from within Emacs lisp code could lead to a different Emacs
environments.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Set the HOME environment variable in Emacs package debug script instead of using it on command line.
  2021-10-26 12:37       ` Hongyi Zhao
@ 2021-10-26 12:49         ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-26 13:39           ` Hongyi Zhao
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-26 12:49 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> my question can be expressed as follows: Set the HOME
> environment variable in shell and from within Emacs lisp
> code could lead to a different Emacs environments.

I use zsh but don't you set it in bash like this?

  export HOME=affe

(You don't do that manually tho, typically.)

You can set it for the Emacs invocation/instance with

  $ HOME=arnold emacs -Q
  (getenv "HOME") ; arnold

(Never did that either, but OK.)

And you can do it from Emacs

  $ emacs -Q
  (setenv "HOME" "stabbe")

(Why ever one would do that.)

And whatever happens after that ... you know? it happens.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Set the HOME environment variable in Emacs package debug script instead of using it on command line.
  2021-10-26 12:49         ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-26 13:39           ` Hongyi Zhao
  2021-10-26 13:58             ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 10+ messages in thread
From: Hongyi Zhao @ 2021-10-26 13:39 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Tue, Oct 26, 2021 at 8:50 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > my question can be expressed as follows: Set the HOME
> > environment variable in shell and from within Emacs lisp
> > code could lead to a different Emacs environments.
>
> I use zsh but don't you set it in bash like this?
>
>   export HOME=affe
>
> (You don't do that manually tho, typically.)
>
> You can set it for the Emacs invocation/instance with
>
>   $ HOME=arnold emacs -Q
>   (getenv "HOME") ; arnold
>
> (Never did that either, but OK.)
>
> And you can do it from Emacs
>
>   $ emacs -Q
>   (setenv "HOME" "stabbe")
>
> (Why ever one would do that.)
>
> And whatever happens after that ... you know? it happens.

Although in these two methods, you get the same HOME variable in
Emacs, this does not mean that the order of the libraries and related
subprocesses called during Emacs startup is exactly the same.

HZ



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Set the HOME environment variable in Emacs package debug script instead of using it on command line.
  2021-10-26 13:39           ` Hongyi Zhao
@ 2021-10-26 13:58             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-10-27  0:40               ` Hongyi Zhao
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-26 13:58 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

> Although in these two methods, you get the same HOME
> variable in Emacs, this does not mean that the order of the
> libraries and related subprocesses called during Emacs
> startup is exactly the same.

These are the methods I'm familiar with.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Set the HOME environment variable in Emacs package debug script instead of using it on command line.
  2021-10-26 13:58             ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-27  0:40               ` Hongyi Zhao
  2021-10-27  0:52                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 10+ messages in thread
From: Hongyi Zhao @ 2021-10-27  0:40 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Tue, Oct 26, 2021 at 9:58 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > Although in these two methods, you get the same HOME
> > variable in Emacs, this does not mean that the order of the
> > libraries and related subprocesses called during Emacs
> > startup is exactly the same.
>
> These are the methods I'm familiar with.

See here [1] for more detailed explanation:

```quoted
Some software uses /etc/passwd instead of the HOME variable.
It's a bug.

Possibly you can inspect 'proxychains-ng-socks5' if it's an script and
fix the bug yourself.

That bug was very common in the past. Fortunately nowadays most
software has fixed it. Ivan Shmakov commented about that in
comp.emacs a pair of years ago:

Ivan Shmakov <iv...@siamics.net> on comp.emacs
Message-ID: <8736wyx2...@violet.siamics.net>

Unfortunately, some software refers to passwd(5) data directly
instead, leaving no way for the user to override the home
directory location. In particular, this was the behavior (IIRC)
of programs based on older Glib versions. And I vaguely recall
that Emacs might have been affected as well.
```

[1] https://groups.google.com/g/comp.unix.shell/c/3vrq7pqoG-A/m/Hnk0lsKfAwAJ

HZ



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Set the HOME environment variable in Emacs package debug script instead of using it on command line.
  2021-10-27  0:40               ` Hongyi Zhao
@ 2021-10-27  0:52                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 10+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-27  0:52 UTC (permalink / raw)
  To: help-gnu-emacs

Hongyi Zhao wrote:

>>> Although in these two methods, you get the same HOME
>>> variable in Emacs, this does not mean that the order of
>>> the libraries and related subprocesses called during Emacs
>>> startup is exactly the same.
>>
>> These are the methods I'm familiar with.
>
> See here [1] for more detailed explanation

Goodbye ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-10-27  0:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-26  2:01 Set the HOME environment variable in Emacs package debug script instead of using it on command line Hongyi Zhao
2021-10-26  5:04 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-26  9:57   ` Hongyi Zhao
2021-10-26 11:25     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-26 12:37       ` Hongyi Zhao
2021-10-26 12:49         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-26 13:39           ` Hongyi Zhao
2021-10-26 13:58             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-27  0:40               ` Hongyi Zhao
2021-10-27  0:52                 ` Emanuel Berg via Users list for the GNU Emacs text editor

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).