Wednesday, April 3, 2013

Re: Setting the TEXINPUTS and BIBINPUTS varibles for latex inside vim/gVim

On 2013-04-02, Christoph Wiesmeyr wrote:
> >
> > Setting environment variables from within an app affects that app and
> >
> > its child apps. So, are you compiling from within vim? ie. do you
> >
> > leave vim and then try latex, bibtex, etc?
> >
> I do not really know how this is implemented in the latex package,
> but I guess I do leave vim for compilation. When I am using vim as
> a child process of the bash, then it works because it seems to use
> the parent for compilation. There the environment variables are
> set correctly in my bashrc.
>
> When I work with gVim (which I generally prefer), then I do not
> really know where it goes when I compile. It seems to leave vim
> and invoke some shell where it can use the pdflatex command.
> However, it apparently does not set the environment variables
> specified in my bashrc there. For me it would be of great interest
> to know how to set variables in this environment invoked by gVim.

Here is an overview of what's going on. There may be exceptions to
the "rules" below, but I'm not going to worry about them for now.

Bash runs in one of two modes: interactive and non-interactive.
The shell you type at at the command line is an interactive shell.
When it starts, it sources ~/.bashrc to obtain aliases, functions,
some enviroment variables, and other things to aid your command line
use.

When bash is invoked as a subshell of another process for the
purpose of running some command, as it is when you run some command
from Vim with ":!command", bash runs in non-interactive mode. To
save start-up time, it does not source your ~/.bashrc since it
usually does not need anything defined there.

Despite what you read on the web, ~/.bashrc is not the right place
to set environment variables. For one thing, they won't be
available to programs launched from Vim with ":!command". For
another, they won't be available to programs started from your
window manager, as gvim often is.

Where you _should_ put environment variables is changing. In the
beginning, personal environment variables were set in ~/.profile.
Period. Then bash came along and offered ~/.bash_profile as an
alternative. Now I understand that Ubuntu recommends putting them
in ~/.environment. I believe that other desktop environments have
their own pet places. For the time being, however, I think that
~/.profile or ~/.bash_profile will still be sourced when you log in
and before your window manager is launched, which is when you want
them set so that they are available to programs such as gvim.

There are (at least) two ways to fix your problem. One, not
recommended, is to force bash to always source your ~/.bashrc even
when it is run non-interactively. The other is to put all your
environment variable settings in ~/.bash_profile.

Also make sure that you export any variable you expect to be used by
a child of the shell.

HTH,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: