Doom-emacs: How to prevent bin/doom from ignoring SSH_AUTH_SOCK?

Created on 26 Jan 2020  ยท  11Comments  ยท  Source: hlissner/doom-emacs

What are you trying to achieve?
Import env variable SSH_AUTH_SOCK into doom-emacs but bin/doom env ingores that variable:

โฏ bin/doom env
> Regenerating envvars file at "~/.emacs.d/.local/env"
- Scraping shell environment
  - Ignoring DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
  - Ignoring TERM=screen-256color
  - Ignoring HOME=/home/XYZ
  - Ignoring PWD=/home/XYZ/.emacs.d
  - Ignoring SSH_AUTH_SOCK=/run/user/1000/ssh-agent.socket

is there a way to include SSH_AUTH_SOCK into list of variables copied into ~/.emacs.d/.local/env ?

System information


((emacs
(version . "26.3")
(features . "XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD LCMS2")
(build . "Aug 29, 2019")
(buildopts "--prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-modules 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now")
(windowsys . batch)
(daemonp))
(doom
(version . "2.0.9")
(build . "HEAD -> develop, origin/develop, origin/HEAD 787f65682 2020-01-20 02:30:11 -0500")
(dir . "~/.doom.d/"))
(system
(type . gnu/linux)
(config . "x86_64-pc-linux-gnu")
(shell . "/bin/zsh")
(uname . "Linux 5.4.10-arch1-1 #1 SMP PREEMPT Thu, 09 Jan 2020 10:14:29 +0000 x86_64")
(path "/usr/local/bin" "/usr/bin" "/bin" "/usr/local/sbin" "/usr/bin/site_perl" "/usr/bin/vendor_perl" "/usr/bin/core_perl" "/opt/intel/mediasdk/bin" "/usr/bin/site_perl" "/usr/bin/vendor_perl" "/usr/bin/core_perl" "/usr/lib/emacs/26.3/x86_64-pc-linux-gnu"))
(config
(envfile . envvar-file)
(elc-files . 0)
(modules :completion company ivy :ui doom doom-dashboard doom-quit hl-todo indent-guides modeline nav-flash neotree ophints (popup +all +defaults) treemacs vc-gutter vi-tilde-fringe window-select workspaces zen :editor (evil +everywhere) file-templates fold multiple-cursors rotate-text snippets :emacs dired electric ibuffer vc :checkers syntax :tools ansible direnv docker (eval +overlay) (lookup +docsets) magit pass :lang data emacs-lisp go (java +meghanada) javascript latex markdown (org +dragndrop +present) php python sh web :config (default +bindings +smartparens))
(packages "n/a")
(elpa "shrink-path" "s" "memoize" "f" "doom-modeline" "dash" "all-the-icons")))

bug question bidoom reenv resolved

Most helpful comment

Try adding this to ~/.doom.d/init.el:

(when noninteractive
  (setq doom-env-ignored-vars (delete "^SSH_AGENT_PID$" doom-env-ignored-vars))
  (setq doom-env-ignored-vars (delete "^SSH_AUTH_SOCK$" doom-env-ignored-vars)))

All 11 comments

one solution is to create your own env file in your doom config, /home/$USER/.doom.d/env and set SSH_AUTH_SOCK= to whatever you need there (in your case this looks like /run/user/1000/ssh-agent.socket)

for doom to actually use these vars, add (doom-load-envvars-file "~/.doom.d/env") to your config

It was intended that Doom loads the user's init.el before bin/doom runs the given command -- to give the user an opportunity to configure the CLI, or define their own commands -- but this is not the case at the moment. Within the next week I'll push a fix to make it so.

Any progress on this? I just ran into it myself. How can I customize the blacklist in my user config?

This workaround worked for me: in your .emacs.d/core/cli/env.el edit the variable doom-env-ignored-vars and comment out or delete the environment variable names that you need.
After that just run bin/doom env again and it shouldn't ignore the variables anymore.

Try adding this to ~/.doom.d/init.el:

(when noninteractive
  (setq doom-env-ignored-vars (delete "^SSH_AGENT_PID$" doom-env-ignored-vars))
  (setq doom-env-ignored-vars (delete "^SSH_AUTH_SOCK$" doom-env-ignored-vars)))

Try adding this to ~/.doom.d/init.el:

(when noninteractive
  (setq doom-env-ignored-vars (delete "^SSH_AGENT_PID$" doom-env-ignored-vars))
  (setq doom-env-ignored-vars (delete "^SSH_AUTH_SOCK$" doom-env-ignored-vars)))

I can confirm that this works as expected. SSH_AUTH_SOCK is written to the env file and emacs picks it up.

Works for me, too! Thanks

Maybe we should add how to modify doom-env-ignored-vars to the help string for doom env.

Ah, I forgot to mention: a recent update broke the snippet I suggested above. In newer versions, doom env has two new sets of switches -a/--allow and -r/--reject, specifying white and blacklist regexps (that override the defaults). This will generate an envvar file with ssh variables preserved, for example:

doom env -a '^SSH_'

Otherwise, doom-env-ignored-vars has been replaced with two variables:

  • doom-env-whitelist
  • doom-env-blacklist

Which can be customized from ~/.doom.d/init.el. e.g.

(when noninteractive
  (add-to-list 'doom-env-whitelist "^SSH_"))

Maybe we should add how to modify doom-env-ignored-vars to the help string for doom env.

Will do!


In any case, this issue can now be considered resolved.

Thanks for taking the time to come back and address this.

I got this to work fairly easily, though I had to change the argument from a list to a string.

(when noninteractive
  (add-to-list 'doom-env-whitelist "^SSH_"))

Ah, my bad. T'was a typo. I've corrected the original post.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ashiklom picture ashiklom  ยท  3Comments

luisenrike picture luisenrike  ยท  3Comments

nasoundead picture nasoundead  ยท  3Comments

randomizedthinking picture randomizedthinking  ยท  3Comments

oyarsa picture oyarsa  ยท  3Comments