Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings env variable for compiler #3008

Open
tonitch opened this issue Oct 4, 2024 · 9 comments
Open

Settings env variable for compiler #3008

tonitch opened this issue Oct 4, 2024 · 9 comments

Comments

@tonitch
Copy link

tonitch commented Oct 4, 2024

Is your feature request related to a problem? Please describe it.
I compile my documents with TEXINPUTS=.:${PWD}/../Commons//:${TEXINPUTS} pdflatex main.tex and it works. I don't find how to set this environment variable when using vimtex
I tried to export the variable before launching vim and this doesn't have effect.

Describe the solution you'd like
I would like a variable (something like g:vimtex_compiler_latexmk['env'] that would be put as env variable before executing the compilation

Describe alternatives you've considered
I don't really know why it doesn't work but maybe the TEXINPUTS should be passed trought ?

@lervag
Copy link
Owner

lervag commented Oct 4, 2024

I tried to export the variable before launching vim and this doesn't have effect.

My intuition here is that you are doing something wrong here. Can you please show, very explicitly and boringly detailed, exactly what you are doing hwen you say the above?

Also, after opening a tex file, can you do :VimtexInfo and copy the output here? It will show some useful contextual info that can help me understand your situation.

@tonitch
Copy link
Author

tonitch commented Oct 4, 2024

for sure. Just for context, here is the makefile I usually use and when I do make, the project compile as intended.

.PHONY: all clean run

export TEXINPUTS := .:${PWD}/../Commons//:${TEXINPUTS}

all: main.pdf

%.pdf: %.tex
	pdflatex $<

clean:
	rm -f main.aux main.log main.nav main.out main.pdf main.snm main.toc texput.log main.fdb_latexmk main.fls main.fdb_latexmk main.fls main.log

run: main.pdf
	xdg-open $<

therefore my strategy is to do

$ export TEXINPUTS=.:${PWD}/../Commons//:${TEXINPUTS} 
$ vim main.tex

(I have a alias vim=nvim in my .profile)
also I can verify that it is exported with echo $TEXINPUTS whitch give me .:/home/tonitch/Documents/workshops/Git_advanced/../Commons//:

here is the error I get when I \ll

main.tex|| File `beamerthemecpumons.sty' not found.
main.tex|13 error| Emergency stop.
main.tex|13 error| ==> Fatal error occurred, no output PDF file produced!

I still can do :echo $TEXINPUTS whitch give me the above env variable

finally, here is the output of :VimtexInfo

System info:
  OS: Arch Linux
  Vim version: NVIM v0.10.1
  Has clientserver: true
  Servername: /run/user/1000/nvim.10679.0

VimTeX project: main
  base: main.tex
  root: /home/tonitch/Documents/workshops/Git_advanced
  tex: /home/tonitch/Documents/workshops/Git_advanced/main.tex
  main parser: current file verified
  document class: beamer
  packages: amsbsy amsfonts amsgen amsmath amsopn amssymb amstext amsthm atbegshi atbegshi-ltx atveryend atveryend-ltx auxhook beamerbaseauxtemplates beamerbaseboxes beamerbasecolor beamerbasecompatibility beamerbasedecode beamerbasefont beamerbaseframe beamerbaseframecomponents beamerbaseframesize beamerbaselocalstructure beamerbasemisc beamerbasemodes beamerbasenavigation beamerbasenotes beamerbaseoptions beamerbaseoverlay beamerbaserequires beamerbasesection beamerbasetemplates beamerbasethemes beamerbasetheorems beamerbasetitle beamerbasetoc beamerbasetranslator beamerbasetwoscreens beamerbaseverbatim beamercolorthemedefault beamerfontthemedefault beamerinnerthemedefault beamerouterthemedefault beamerthemedefault bigintcalc bitset enumerate environ etoolbox fontenc geometry gettitlestring graphics graphicx hycolor hyperref iftex ifvtex infwarerr inputenc intcalc keyval kvdefinekeys kvoptions kvsetkeys ltxcmds nameref pdfescape pdftexcmds pgf pgfcomp-version-0-65 pgfcomp-version-1-18 pgfcore pgffor pgfkeys pgfmath pgfrcs pgfsys refcount rerunfilecheck sansmathaccent scrlfile scrlfile-hook scrlogo tcolorbox tikz tikzfill-common tikzfill.image translator trig trimspaces uniquecounter url verbatim xcolor xxcolor
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
    job: 
      jobid: 10
      output: /tmp/nvim.tonitch/NNXPaT/0
      cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode  -pdf -pvc -pvctimeout- -view=none -e '$compiling_cmd = ($compiling_cmd ? $compiling_cmd . " ; " : "") . "echo vimtex_compiler_callback_compiling"' -e '$success_cmd = ($success_cmd ? $success_cmd . " ; " : "") . "echo vimtex_compiler_callback_success"' -e '$failure_cmd = ($failure_cmd ? $failure_cmd . " ; " : "") . "echo vimtex_compiler_callback_failure"' 'main.tex'
      pid: 10752
  viewer: Zathura
    xwin id: 0
  qf method: LaTeX logfile

hope this help, I already did all of that before posting the issue, but maybe you have a sharper eyes ^^

Thanks for your help!

@lervag
Copy link
Owner

lervag commented Oct 5, 2024

Thanks, this helps. It's still hard to say exactly what is wrong here. I have two ideas for inspecting this further:

  1. If you could provide a minimal example, that would be the best. This includes a minimal .vimrc or init.lua file and a small mwe.tex file with which you can reproduce the problem. If I can reproduce your problem, I would be able to fix it.

  2. We can remote debug on your side. I'll continue helping with this, but it will take more time.


Remote debugging: The next step is to see if you can reproduce this problem with latexmk in a terminal. It should suffice to do this:

latexmk -c
export TEXINPUTS=.:${PWD}/../Commons//:${TEXINPUTS}
latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode  -pdf -pvc -pvctimeout- -view=none 'main.tex'

Does this work as expected?

@tonitch
Copy link
Author

tonitch commented Oct 6, 2024

Thanks for your help, here is a small template project I just made to test and the bug appears as well
https://github.com/tonitch/tex-example
I can compile using the makefile and I tried using the command you proposed and they works perfectly fine.
You can find my dotfiles at : https://git.herisson.ovh/tonitch/dotfiles
the relevant folders are vim and nvim
I haven't tried to isolate vimtex yet.
Something that could maybe cause something to behave weirdly is that I don't use any plugin manager, all my "plugins" are installed using the pack functionnaily of vim

@lervag
Copy link
Owner

lervag commented Oct 9, 2024

Thanks for your help, here is a small template project I just made to test and the bug appears as well https://github.com/tonitch/tex-example I can compile using the makefile and I tried using the command you proposed and they works perfectly fine.

I've tested your example, and for me, everything works exactly as expected; i.e., both of the following approaches work for me:

# 1
TEXINPUTS=.:${PWD}/../Commons//:${TEXINPUTS} nvim main.tex

# 2
export TEXINPUTS=.:${PWD}/../Commons//:${TEXINPUTS}
nvim main.tex

So, I think your problem is somehow tied to your config.

@lervag
Copy link
Owner

lervag commented Oct 9, 2024

You can find my dotfiles at : https://git.herisson.ovh/tonitch/dotfiles the relevant folders are vim and nvim

I've looked at your config, and there is nothing that stands out to me as wrong here. Out of curiosity, do you have the same problem with both Vim and neovim?

I haven't tried to isolate vimtex yet.

In my opinion, that is the sensible next step. Here's a classical, minimal init.lua that you could use to debug:

-- NOTE: Fix the path in the following two lines:
vim.opt.runtimepath:prepend "~/.local/plugged/vimtex"
vim.opt.runtimepath:append "~/.local/plugged/vimtex/after"
vim.cmd [[filetype plugin indent on]]

vim.g.vimtex_view_method = "zathura"
vim.g.vimtex_cache_root = "."
vim.g.vimtex_cache_persistent = false

With the above saved as mwe.lua, you can test with

# First, verify that you still get the same problem as before
nvim --clean -u mwe.lua main.tex

# Now check if the env variable is picked up; this _should_ work:
export TEXINPUTS=.:${PWD}/../Commons//:${TEXINPUTS}
nvim --clean -u mwe.lua main.tex

Something that could maybe cause something to behave weirdly is that I don't use any plugin manager, all my "plugins" are installed using the pack functionnaily of vim

Ah, yes. I personally really don't like the builtin pack feature and I would strongly recommend to use a plugin manager. In any case, can you please explain in more depth how you've installed VimTeX? It could be related to this.

@tonitch
Copy link
Author

tonitch commented Oct 9, 2024

I've looked at your config, and there is nothing that stands out to me as wrong here. Out of curiosity, do you have the same problem with both Vim and neovim?

I did now and I have the same problem with vim

In my opinion, that is the sensible next step.

I will try that in a moment (or maybe tomorrow as I have class early) thanks for your help so far!

Ah, yes. I personally really don't like the builtin pack feature and I would strongly recommend to use a plugin manager. In any case, can you please explain in more depth how you've installed VimTeX? It could be related to this.

I used to use Vundle but ditched it. Basicly now, I use git to manage my plugins. each folder in .vim/pack/*/start/ is a repo and is loaded by vim automagicly. so vimtex is not different, this is just the repo in this folder I don't think I did anything more

@lervag
Copy link
Owner

lervag commented Oct 10, 2024

I've looked at your config, and there is nothing that stands out to me as wrong here. Out of curiosity, do you have the same problem with both Vim and neovim?

I did now and I have the same problem with vim

Ok; for now, let's focus on neovim. I guess solving it for neovim would also solve this for Vim.

In my opinion, that is the sensible next step.

I will try that in a moment (or maybe tomorrow as I have class early) thanks for your help so far!

No problem; it's hard to help much further without being able to reproduce this.

Ah, yes. I personally really don't like the builtin pack feature and I would strongly recommend to use a plugin manager. In any case, can you please explain in more depth how you've installed VimTeX? It could be related to this.

I used to use Vundle but ditched it. Basicly now, I use git to manage my plugins. each folder in .vim/pack/*/start/ is a repo and is loaded by vim automagicly. so vimtex is not different, this is just the repo in this folder I don't think I did anything more

Yes, if you do this correctly I agree it should work. There are some gotchas, but I think most of them are addressed here:

**Note**: If you use the built-in package feature, then:

But I don't see immediately how this should be relevant.


Another simple test: Run FOO=bar nvim and then :echo $FOO - what's the output? How does it work if you do the TEXINPUTS variable?

@user202729
Copy link

user202729 commented Oct 13, 2024

One possibility is latexmk caching --- latexmk will not rerun even if environment variables has changed.

Try running :VimtexCompileOutput in vim after you've triggered a run. If it says "Nothing to do" then you know that's the issue.

Delete all log, pdf, fdb_latexmk etc. files and try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants