purcell / exec-path-from-shell

Make Emacs use the $PATH set up by the user's shell
Other
1.43k stars 82 forks source link

Variable from .profile not set #94

Closed floli closed 10 months ago

floli commented 5 years ago

Hello,

I have an export MYVAR=path in my ~/.profile and it is set as it should on normal shells, .i.e,, the ones in a terminal.

However, in Emacs, without any special config for exec-path-from-shell, just calling exec-path-from-shell-initialize, it is not set (as verified by calling set from shell-command (M-!)).

The package gives the message:

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 disable ‘exec-path-from-shell-check-startup-files’ to disable this message.

Which confuses me somewhat. It says that everything will work, but I should fix it by moving variable setup to .profile and alike, and when finished, configure exec-path-from-shell-arguments?

However, why is $MYVAR not set? I think it should on interactive, login shells:

$ unset MYVAR
$ bash -i -l
$ echo $MYVAR
path

Best Thanks!

purcell commented 5 years ago

You can enable exec-path-from-shell-debut, then exec-path-from-shell-initialize should tell you a little more about what it's running and what output it's seeing. The message you've reproduced basically indicates that MYVAR would not be printed out if the shell had not been given the -i or -l flag. Note also that not all the env vars set by your shell are copied by exec-path-from-shell, so you might have to add MYVAR to the var list before calling exec-path-from-shell-initialize.

purcell commented 5 years ago

BTW you didn't really explain in a structured way what you tried, what you expected, and what happened, so I'm having to guess at information that might be helpful to you.

iburunat commented 4 years ago

Hi, I'm having the same "warning" problem. The issue is that moving all my environment variables (as suggested by the warning message) to .zshenv, does only solve the warning at the cost of messing with the operation of some packages (i.e., ob-ipython). I think the order or sourcing of the .bashrc/.zshrc, .zchenv, .zprofile files plays a role here, and so moving all $PATH variables to .zshenv could be overriding the previously working settings.

purcell commented 10 months ago

Closing because this is more of a question about shell startup file configuration, and fixing it is not something in the scope of this package.