2

I'm on Windows 7, running GNU Emacs 24.4.1, and I have also installed Cygwin and I am trying to use Cygwin as the shell in Emacs. I followed the answer here:

https://stackoverflow.com/questions/235254/how-can-i-run-cygwin-bash-shell-from-within-emacs

And have this in my init-file

(setq shell-file-name "C:/cygwin64/bin/bash")
(setq explicit-shell-file-name shell-file-name)
(setenv "PATH"
(concat "~/bin:/usr/local/bin:/usr/bin:"
    (replace-regexp-in-string " " "\\\\ "
        (replace-regexp-in-string "\\\\" "/"
            (replace-regexp-in-string "\\([A-Za-z]\\):" "/\\1"
                (getenv "PATH"))))))

When I try to compile on Latex, I get this error: "ERROR: LaTeX Error: File `fullpage.sty' not found."

Disabling cygwin in my init file fixes the problem. I feel like enabling Cygwin might mess up Emacs with path names, so it can't find the fullpage.sty and other Latex packages. Anyone ideas on how to fix this?

bkmoney
  • 323
  • 3
  • 10
  • 1
    Is this an Emacs problem or a Cygwin problem? It sounds more like the latter, and if so, we could migrate this to Stack Overflow. – Dan Apr 27 '15 at 20:24
  • I think this is an Emacs problem with how my Emacs is setup to incorporate Cygwin. – bkmoney Apr 27 '15 at 20:30
  • First of all, your problem is that you are trivially missing a LaTeX package (*.sty files are the LaTeX package files, well, in the first approximation). Either download it from https://www.ctan.org/pkg/fullpage or use Cigwin to locate the package and install it using Cygwin (I bet the later will be easier, but you might as well do the former to get acquainted with the way LaTeX packages are installed.) – wvxvw Apr 27 '15 at 20:30
  • @wvxvw When I remove the Cygwin part from my .emacs file, there is no error and it can build the Latex file fine, so I'm pretty sure I have the necessary .sty files – bkmoney Apr 27 '15 at 20:31
  • There could be more than one explanation to it: you have installed TeXLive from Cygwin repository and now you are dealing with a different LaTeX setup. Or, LaTeX itself had been installed for Windows, and doesn't know where to find its parts, if run from a nix shell. I'm not sure if you can set up a Windows version of LaTeX to be able to locate files when run from a nix shell. I'd rather look at the http://tex.stackexchange.com/ for the answer to that. – wvxvw Apr 27 '15 at 20:36
  • Actually, if you know where fullpage.sty really is, you can try to symlink the texfm directory to $HOME/texfm at least just to try and see if it changes anything. – wvxvw Apr 27 '15 at 20:45
  • @Dan I think it could go either way. Personally, I don't think there's enough information about the problem to make a call. – nanny Apr 27 '15 at 20:56
  • Ok I realized that it's using the Cygwin version of Latex which doesn't have fullpage.sty, so I followed instructions on another site and have added this to my .bashrc file "PATH="/cygdrive/c/Program Files (x86)/MiKTeX 2.9/miktex/bin":$PATH"

    The weird thing is, if I open up a Cygwin terminal now and do pdflatex filename.tex, everything works fine. However when I open up a shell from Emacs, and do the same thing, it still has the error. Does the emacs shell automatically use your .bashrc file, or do I have to configure that?

    – bkmoney Apr 27 '15 at 21:09

1 Answers1

1

The problem is that .bashrc is only loaded in interactive mode. Doing a C-c C-b to compile in latex mode executes a shell-command, which is by default non interactive. If you add these lines to your emacs init file:

(setq shell-file-name "bash")
(setq shell-command-switch "-ic")

Now any shell-commands will be run interactively. Also as a side note maybe people should enable this anyways because it allows you to use your bashrc aliases when executing shell-command.

Scott Weldon
  • 2,695
  • 1
  • 18
  • 31
bkmoney
  • 323
  • 3
  • 10