jcfaria / Vim-R-plugin

Plugin to work with R (forked for development only)
http://www.vim.org/scripts/script.php?script_id=2628
121 stars 34 forks source link

Conserve environmental bash variables. #169

Closed phcerdan closed 9 years ago

phcerdan commented 9 years ago

The R console called from vim doesn't conserve the environmental bash variables. I have discovered it using a non-default latex/pdftex. and library("tikzDevices"). If I add the non-default latex into $PATH in bash, and then execute R console, it recognizes the new path correctly: getOption("tikzLatex") = /path/to/non-default/pdftex

But if I do the same (source ~/bin/texlive.sh), then execute vim, and then use \rc to prompt the R console, that R console does not recognize the new path. getOption("tikzLatex") = /usr/bin/pdftex

As a workaround, I can explicitly set them, but well, not the optimal solution. options(tikzDefaultEngine = 'pdftex') options(tikzLatex="non-default/path/pdftex");

My guess is that R is called from a new-default bash, is there any way to modify what is loaded in the environment of that new bash, beyond .bashrc? I am using tmux by the way...

jalvesaq commented 9 years ago

Can you try to control this in your .bashrc? You could test if the environment variable VIMRPLUGIN_TMPDIR exists and is not empty and, then, do something, like source /path/script.sh.

jalvesaq commented 9 years ago

I think I cannot control this from the Vim-R-plugin because this is a Tmux feature. You may try to put in ~/.tmux.conf (not tested):

set -g update-environment VARIABLE1 VARIABLE2

Please, look Tmux man page.

phcerdan commented 9 years ago

That makes sense, thanks for pointing out the tmux option. I will test it and post it for completeness.

phcerdan commented 9 years ago

It is a bit risky to conserve the $PATH and $LD_LIBRARY_PATH in tmux sessions with the update-environment option. At the end, I am just:

source texlive.sh
tmux new -s Rsession

and the variables are conserved when a new pane, or window is opened inside that session. Thanks, I apologize because this is not a vim R plugin issue.

jalvesaq commented 9 years ago

Thanks for the feedback!