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

Does not copy needed variables when using ansi-term #66

Closed computersarecool closed 7 years ago

computersarecool commented 7 years ago

Hi, This package has helped out a lot. I use ansi-term as a terminal inside of emacs on Ubuntu and prior to using this package that shell was almost unusable. However, as helpful as this package is, it still seems like a few variables that I wish were set are not set.

I notice in your README you say:

This library solves this problem by copying important environment variables from the user's shell

but I wonder why you don't just copy all of the environment variables. When I open a new instance of ansi-term my .profile is not read, so the environment variables that are there (where I set most of them) are not configured.

Specifically I am missing:

EDITOR
VISUAL
MONGO_PATH

and my PATH is missing several directories. Is there a reason you do not extract all environment variables / is there a good way to do so?

purcell commented 7 years ago

ansi-term has nothing to do with this package, in this case.

Look to see how ansi-term starts your shell: command-line arguments passed to the shell (e.g. -i, -l) will generally determine whether your .profile and other startup files are read. Read the man page for bash, for example.

computersarecool commented 7 years ago

My understanding is that ansi-term inherits the shell from emacs, so when exec-path-from-shell sets certain environment variables for emacs, those too are set in ansi-term. Is it not possible to get exec-path-from-shell to make the emacs environment variables identical to those of a shell (i.e. with all environment variables set)?

purcell commented 7 years ago

Nope. It's actually not practical to make a shell tell you just the names of all its active environment variables. You'd think it would be possible to just run env and parse its output, but values can contain newlines and the = character, so you can imagine all the things that can go wrong. :-)

But you can add more variables to exec-path-from-shell-variables, and you'll get the behaviour you want.

computersarecool commented 7 years ago

Ah, that is what I was looking for. Thank you.