Skip to content

mkdir tries to create current directory when TeX file in parent and .latexmkrc specifies "build" #3224

@ordinary-slim

Description

@ordinary-slim

Description

With this project structure

.
├── metadata.tex
└── subfolder
    ├── .latexmkrc
    └── main.tex

and .latexmkrc specifying

$out_dir = 'build';
$aux_dir = 'build';

VimtexCompile errors in its first run, trying to create the current folder when build is still absent:

VimTeX: Creating directorie(s):
        * [...]/subfolder/build/..
Error detected while processing function vimtex#compiler#compile[7]..vimtex#compiler#start[18]..38[3]..56[1]..32:
line   29:
E739: Cannot create directory [...]/subfolder/build/..: file already exists

This boils down to call mkdir("./build/..", "p"), and build has not been created yet. This errors despite the "p" flag. After the first run, the project structure is:

.
├── metadata.tex
└── subfolder
    ├── build
    ├── .latexmkrc
    └── main.tex

and consequent runs don't error.

Steps to reproduce

  1. https://github.com/ordinary-slim/vimtex-mkdir-bug
  2. I believe this will error regardless of the config. Open main.tex in subfolder and run `VimtexCompile

Expected behavior

Vimtex should not try to mkdir the current folder, and not like this: ./build/.., where build is still absent.

Actual behavior

Vimtex runs mkdir("./build/..", "p"), where build is still absent, and errors in its first run.

Do you use a latexmkrc file?

Yes

VimtexInfo

System info:
  OS: Linux 6.17.5-arch1-1 (I use arch btw)
  LaTeX version: pdfTeX 3.141592653-2.6-1.40.28 (TeX Live 2025)
  Vim version: NVIM v0.11.4
  Has clientserver: true
  Servername: /run/user/1000/nvim.134803.0
  $PATH:
    - /bin
    - /home/mehdi/.local/bin
    - /home/mehdi/.local/share/nvim/mason/bin
    - /sbin
    - /usr/bin
    - /usr/bin/core_perl
    - /usr/bin/site_perl
    - /usr/bin/vendor_perl
    - /usr/local/bin
    - /usr/local/sbin
    - /usr/local/texlive/2025/bin/x86_64-linux
    - /usr/sbin

VimTeX project: main
  base: main.tex
  root: /home/mehdi/Documents/bug-vimtex/subfolder
  tex: /home/mehdi/Documents/bug-vimtex/subfolder/main.tex
  main parser: current file verified
  document class: article
  document class options: 
  source files:
    main.tex
    ../metadata.tex
  compiler: latexmk
    engine: -pdf
    options:
      -pdf
      -shell-escape
      -verbose
      -file-line-error
      -interaction=nonstopmode
      -synctex=1
      -f
    out_dir: build
    aux_dir: build
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: Zathura
    xwin id: 0
  qf method: LaTeX logfile

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions