0

I installed texlive and I want to add it as an environment variable to my Path so that Emacs AucTeX can read it when I start emacs from the GUI or from the command line. So far I've read that emacs only reads files from ~/.profile

Therefore my plan is to add texlive to my path in .profile to enable emacs GUI to read it and then source ~/profile from .bashrc in order for emacs that is started inside my non-login interactive Gnome terminal to see the path.

Note: I do not have a .profile file in my home directory. Only in my etc directory and I rather not touch that one, but I have a .bash_profile in my home directory. However I read that .bash_profile is only run for an interactive login session aka console mode which I don't use.

My plan is to create a .profile file in my home directory and do the following:

step 1: Create ~/.profile

Step 2: Add texlive environment variable to path in .profile

export PATH=/usr/local/texlive/2018/bin/x86_64-linux:$PATH
export MANPATH=/usr/local/texlive/2018/texmf-dist/doc/man:$MANPATH
export INFOPATH=/usr/local/texlive/2018/texmf-dist/doc/info:$INFOPATH

Step 3: Source .profile from .bashrc

#Adding this at the bottom or start of .bashrc to source .profile when the terminal is opened.

if [-s ~/.profile]; then;
    source ~/.profile;
fi

I know that there is a lot of apprehension towards sourcing .profile from .bashrc due to the risk of causing an infinte loop. However since I am creating a .profile file from scratch this will not be a problem as it will not contain any code that references .bashrc.

My Questions:

  1. What do you think of my plan?
  2. Do you think it will work?
  3. Do you have any suggestions on how to improve it or perhaps other alternatives

Additional info: My .bashrc only contains code that sources ~/etc/bashrc and one environment variable that was automatically added by Anaconda: export PATH="/home/Fedora_User/Anaconda3/bin:$PATH"

Keep in mind that I know the gnome-terminal can be run as an interactive login shell but I have never done this and dont know if it will impact the performance of my terminal sessions.

  • 1
    emacs isn't going to read ~/.profile, it reads ~/.emacs which contains elisp. Do you mean programs started from within emacs, such as shell, might read ~/.profile? – meuh May 12 '18 at 13:20
  • I remember reading that emacs reads .profile [emacs.stackexchange.com/q/37291/19261 ]. Or let me rephrase it: To find environment variables emacs reads .profile. This is why this exists: Github. Additionally, AucTeX in emacs will need to read .profile – MyWrathAcademia May 12 '18 at 13:30
  • 1
    emacs does not read .profile, but if it is executed from a shell that has read the profile and has exported an env variable, then it will "know" the variable because it inherits the environment of the invoking shell. This is NOT specific to emacs: any program that is started by such a shell wil inherit the environment, so if it chooses it can find out the value of the env variable. – NickD May 12 '18 at 13:58
  • If you have an OS using systemd (>=233) you could consider this "future proofed" suggestion of putting assignments in files like ~/.config/environment.d/my.conf. It is not specific to Wayland, though that is the motivation. – meuh May 12 '18 at 14:03
  • 1
    Crossposting: askubuntu.com/q/1035262/336375 – Cyrus May 12 '18 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.