I am on Ubuntu. I'm trying to run the latex command to run in the Emacs shell. I have done some research, and have already done the following:

I noticed that running env in the Emacs shell gave a different value for PATH than running env in the normal terminal. I installed purcell's exec-path-from-shell to solve this. Following the directions, I copied my current terminal PATH, went to .profile, commented out lines of the kind PATH = something_new:PATH and just replaced it all with PATH=my_whole_copied_path. I then added (exec-path-from-shell-initialize) just after (package-initialize) in my .emacs.

After doing this, running env in Emacs shell gives the same PATH as running env in my terminal. The latex binary lives in /opt/texbin, and my current Emacs PATH reads:


Still, running latex give command not found. What am I missing?

Update: I have learned that /opt/texbin is actually a symlink to a different location, and I've noticed that I can't cd into it in the Emacs shell. Could this be why this isn't working? Can I get shell to understand symlinks with an option?

1 Answer 1


Solved it: it was because Emacs was installed as a flatpak. For some reason, this mean the Emacs shell had many differences. I wasn't able to cd into certain folders. Other folders didn't exist: /usr/local, for example.

After uninstalling, and re-installing from the Ubuntu repository, everything works as expected.

I hope this can be helpful to someone. My PATH was setup fine, and I was still running into this problem. I'd love it if someone could explain why installing it as a flatpak caused the Emacs shell to "see" such a different set of directories.

  • Ran into the same issue, my solution was installing from snap.
    – nland
    Commented Jan 13, 2021 at 22:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.