0

This question already has an answer here:

I have updated the question after an answer to a related question : see the later pragraphs.

When I startup spacemacs I get the following warning:

You appear to be setting environment variables ("PATH") in your .bashrc or .zshrc: those files are only read by interactive shells, so you should instead set environment variables in startup files like .profile, .bash_profile or .zshenv. Refer to your shell's man page for more info. Customize exec-path-from-shell-arguments' to remove "-i" when done, or disableexec-path-from-shell-check-startup-files' to disable this message

Does this warning refer to the PATH variable specifically or does it refer to all environment variables? The message seems to assume that login shells are the ones where environment variables to be set.

If that is the case what are the kind of settings are appropriate for the configuration files for interactive shells , ie .zshrc and .bashrc, as opposed to those in .profile which depend or are related to an established user identity?

After asking at emacs stackexchange I have learned the message is set by an emacslibrary which copies environment settings from .profile to make them available to scripts run by emacs.

The warning suggests that environment variables set in .bashrc are not available to scripts (which are non-interactive shells) but those in .profile are.

Does that mean that environment variables set in .bashrc will not be available to a script run via #!/bin/sh even if /bin/sh is linked to bash, or even if the script is run via #!/bin/bash?

marked as duplicate by Gilles, Satō Katsura, Archemar, GAD3R, Rui F Ribeiro Jun 10 '17 at 21:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I have read that question, but unfortunately most of the answers don't explain the use cases, eg what makes some settings appropriate in one file, but not in another e.g why an interactive shell config like .bashrc will not pass environment variables set within it to scripts. – vfclists Jun 9 '17 at 14:22
  • Do you ever use something like ssh host spacemacs ? That neatly bypasses any interactive configuration for ZSH. – thrig Jun 9 '17 at 14:30