I've added a few environment variables to my .bashrc file, some of these are paths to customized bin/programs, such as:

export MY_ENV_PATH_VAR=/home/user/path/to/bin

I've refreshed spacemacs' .spacemacs.env file by running SPC f e E, however these new variables in my .bashrc are not being included in .spacemacs.env.

The beginning of the .spacemacs.env file points out that variables which names match spacemacs-ignored-environment-variables will not be included, however, I don't know how/where to check these regexps.

I've tried to go around this problem by adding the variables directly to the spacemacs.env file and this seems to work sporadically, sometimes the variables are picked up and sometimes they're not and I get errors such as (Spacemacs) Error in dotspacemacs/user-env: Wrong type argument: stringp, nil

In my case, I'm calling (add-to-list 'exec-path (getenv "MY_ENV_PATH_VAR")) from dotspacemacs/user-config function.

  • What happens if you just restart emacs?
    – mmmmmm
    Commented Sep 9, 2022 at 18:34
  • Whenever I restart I get the sporadic error of (Spacemacs) Error in dotspacemacs/user-env: Wrong type argument: stringp, nil. Sometimes it shows and sometimes it works and the variables are picked up. The error showing up is more common though.
    – stigma
    Commented Sep 9, 2022 at 19:56
  • For now I've worked around this by just adding my variables directly into the .spacemacs.env file, that seems to work. I'd love for these to just leave in my .bashrc file though and Spacemacs get them from there.
    – stigma
    Commented Sep 9, 2022 at 20:06
  • What happens if you have no .spacemacs.env - also what OS are you running?
    – mmmmmm
    Commented Sep 9, 2022 at 20:08
  • @mmmmmm the .spacemacs.env file is just re-created when I start emacs/emacsclient again. I'm running Ubuntu 22.04
    – stigma
    Commented Sep 12, 2022 at 12:53


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.