0

I have a gitlab runner installed on my machine and all the needed things to run my .gitlab-ci.yml But when I run it everything succeeds except it doesn't recognize the command: latexmk 'latexmk' is not recognized as an internal or external command, operable program or batch file.

When I run the command myself (in the exact same folder) it does recognize it.

My .gitlab-ci.yml is as followed and runs with powershell:

stages:
  - build
  - test
  - deployment

pages:
  stage: deployment
  script:
    - pip install -U sphinx
    - pip install sphinxcontrib-needs
    - pip install sphinxcontrib-plantuml
    - pip install sphinxcontrib-programoutput
    - pip install sphinx-book-theme
    - cd documentation
    - .\make.bat html
    - mv build\doctrees ..\public
    - mv build\html ..\public
    - .\make.bat latex
    - .\generation_pdf.bat
    - cd ..
  artifacts:
    paths:
      # The folder that contains the files to be exposed at the Page URL
      - public

Short story on how it works: it creates a lot of files from the .\make.bat latex command and then a file inside there that gets run through the command call make containing the following:

@ECHO OFF

REM Command file for Sphinx documentation

pushd %~dp0

set PDFLATEX=latexmk -pdf -dvi- -ps-

set "LATEXOPTS= "

set XINDYOPTS=-L english -C utf8  -M sphinx.xdy
set XINDYOPTS=%XINDYOPTS% -I xelatex
if "%1" == "" goto all-pdf

if "%1" == "all-pdf" (
    :all-pdf
    for %%i in (*.tex) do (
        %PDFLATEX% %LATEXMKOPTS% %%i
    )
    goto end
)

if "%1" == "all-pdf-ja" (
    goto all-pdf
)

if "%1" == "clean" (
    del /q /s *.dvi *.log *.ind *.aux *.toc *.syn *.idx *.out *.ilg *.pla *.ps *.tar *.tar.gz *.tar.bz2 *.tar.xz *.fls *.fdb_latexmk
    goto end
)

:end
popd

Hopefully someone can help me,

Jesse

I already tried preforming the same as the gitlab runner did from the exact same location. Also just running the call make command.

Fix 1: The path to latex wasn't in the environment variables for the runner, I added it by adding pre_build_script = "$Env:PATH += \";C:\\PathToMiktexFolder\"" to the runners config.toml file

This solved it but generated a different error: It seems that this is a fresh TeX installation. Please finish the setup before proceeding. For more information, visit: miktex.org/howto/install-miktex-win

Fix 2: I uninstalled miktex and instead installed tex live, as I didn't find a way to 'finish the setup' as I just installed the application and then installed the latex package via the package manager.

Geitjee
  • 11
  • 4
  • I'm guessing the binary is not on `PATH` for the runner. Try using the full path to the `latexmk` e.g., something like `C:\latexmk\latexmk.exe` or whatever (use `where latexmk` in cmd on your user account to find it). Alternatively, you can try configuring your runner's `PATH` environment variable to be the same as your user account. – sytech Mar 17 '23 at 17:04
  • @sytech This solved the problem, I added the path in the config.toml file by adding `pre_build_script = "$Env:PATH += \";C:\\PathToMiktexFolder\""` but I now get the error: `latexmk: security risk: running with elevated privileges It seems that this is a fresh TeX installation. Please finish the setup before proceeding. For more information, visit: miktex.org/howto/install-miktex-win` – Geitjee Mar 20 '23 at 12:03
  • Fixed the issue by uninstalling miktex and using tex live instead, didn't find a way to 'finish the setup' as I just installed the application and then installed the latex package via the package manager. – Geitjee Mar 27 '23 at 13:51

0 Answers0