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

Resolving file references should take working directory of run configuration into account #3679

Open
MartinX3 opened this issue Oct 9, 2024 · 13 comments
Labels
bug Deficiencies in TeXiFy behaviour.

Comments

@MartinX3
Copy link

MartinX3 commented Oct 9, 2024

Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version

IntelliJ IDEA 2024.2.3

Operating System

Arch Linux

TeXiFy IDEA version

0.9.7

What I did (steps to reproduce)

A tex file is in a subdirectory.
The \input and \RequirePackage parameters are absolute paths from the base directory.

Latexmk compiles everything just fine.

Minimal example to reproduce the problem

#path abschnitte/unterordner/Text.tex

\documentclass{moderncv}
\input{datenbanken/Meta}
\RequirePackage{aussehen/CV}
\begin{document}
    blablabla
\end{document}

#path aussehen/CV.sty

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{aussehen/CV}[2024/08/19 cv theming Package]

\moderncvcolor{blue}
\moderncvstyle{casual}

% Die Seitenränder anpassen
\RequirePackage[scale=0.75]{geometry}

% Dinish Schriftart. Siehe https://github.com/playbeing/dinish
\RequirePackage{fontspec}
\RequirePackage{unicode-math}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont[
    Extension = .otf,
    Path = aussehen/font/,
    UprightFont = *-Regular,
    BoldFont = *-Bold,
    ItalicFont = *-Italic,
    BoldItalicFont = *-BoldItalic
]{DINish}
\setsansfont{Latin Modern Sans}
\setmonofont{Latin Modern Mono}
\setmathfont{Latin Modern Math}

\RequirePackage[ngerman]{babel}

% Fix Package fancyhdr Warning: \footskip is too small (30.0pt)
\setlength{\footskip}{68.00002pt}

% TODO WORKAROUND avoid orphaned section headers until moderncv 2.4.1
% https://github.com/moderncv/moderncv/issues/10
% https://github.com/xdanaux/moderncv/issues/82
\RequirePackage{needspace}
\newcommand{\sectionavoidpagebreak}[2]{
    \needspace{3\baselineskip}
    \section{#1}\label{sec:#2}
}

#path datenbanken/Meta.tex

% Brief
\recipient{Company Recruitment team}{Company, Inc.\\Somestreet 123\\Somestadt}
\date{Ort, \today}
\opening{Sehr geehrte Damen und Herren,}
\closing{Mit freundlichen Grüßen}
\enclosure[Anhang]{Lebenslauf}

% Lebenslauf
\name{Max}{Mustermann}
\title{Zusammenfassender Titel}
\born{4. Juli 1776}
\address{Musterstr. 42}{53123 Bonn}{Germany}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\email{[email protected]}
\homepage{https://www.maxmustermann.com}

\extrainfo{Zusätzliche Informationen}
\photo[64pt][0.4pt]{anhang/Profilfoto}
\quote{Irgendein Zitat}

Expected behavior

No error.

Actual behavior

It claims the file is not found.
Also if I use the auto fix to let it create the file it is always lowercase.

(if applicable) The full stacktrace of the exception thrown

N/A
@MartinX3 MartinX3 added bug Deficiencies in TeXiFy behaviour. untriaged Issue type still needs to be triaged or verified. labels Oct 9, 2024
@PHPirates
Copy link
Collaborator

It claims the file is not found.

Which file is not found? Works fine for me:

image

@PHPirates PHPirates added more-info-needed More information is needed from the person filing the issue. and removed untriaged Issue type still needs to be triaged or verified. labels Oct 31, 2024
@MartinX3
Copy link
Author

MartinX3 commented Nov 2, 2024

My project structure is a bit different because the document is in a subsubfolder:

  • abschnitte/Bewerbung/Lebenslauf.tex
  • aussehen/CV.sty
  • datenbanken/Meta.tex

But this error is only cosmetic.
The IDE / latexmk (lualatex) compiles it just fine.

image

@PHPirates
Copy link
Collaborator

Thanks! So how exactly do you compile your document, that that works?

I recreated the structure:
image

So if Lebenslauf.tex is the main file, and I run latexmk -pdf Lebenslauf.tex, then it won't compile, and that is what the inspection warns you for (apparently incorrectly).

@MartinX3
Copy link
Author

MartinX3 commented Nov 5, 2024

I am in the root of my project and execute my Makefile.
In the end it executes without any issues the following statement:
latexmk -lualatex --output-directory=out/Bewerbung abschnitte/Bewerbung/*

In my case pdflatex won't work because I use the fontspec package.
(But lualatex is the successor of pdflatex, so I'm fine)

PS:
Changing the path to \input{../../../../datenbanken/Meta} won't remove that error message, even if the auto completion of the code shows the file.
image
image

And it won't compile (probably because the Makefile is in the root).

! LaTeX Error: File '../../../../datenbanken/Meta.tex' not found.

@PHPirates
Copy link
Collaborator

PHPirates commented Nov 5, 2024

Ah, so what is in the Makefile, and where is the Makefile located? If the Makefile does something other than just running a command (which I expect it does, otherwise it would't compile - I'm guessing the working directory) then it is expected that TeXiFy inspections won't work.

The real question is, why are you using a Makefile and organising files like that (in a way that would not compile without the Makefile)?

@MartinX3
Copy link
Author

MartinX3 commented Nov 5, 2024

The makefile just dynamically builds the command I quoted.
So as example the texfiles in the Bewerbung Folder will be compiled to one *.pdf file each *.tex file in the out/Bewerbung folder.

I have 3 different folders to seperate my general application papers, question lists and notes about interviews with different companies.
Otherwise it would be all in a big out folder and also a mess in the code folder.

The makefile:

default | help:
	@echo 'make | Zeigt die Hilfe'
	@echo 'make build | Erstelle alle Dokumente mit latexmk'
	@echo 'make build_application | Erstelle die Bewerbung mit latexmk'
	@echo 'make build_job_search | Erstelle die Jobdaten mit latexmk'
	@echo 'make build_questions | Erstelle die Interviewfragen mit latexmk'
	@echo 'make clean | Säubere das Arbeitsverzeichnis von temporären Dateien und Verzeichnissen.'
	@echo 'make help | Zeigt die Hilfe'

build: build_application build_job_search build_questions

build_application:
	$(call compile,Bewerbung)

build_job_search:
	$(call compile,Jobsuche)

build_questions:
	$(call compile,Fragen)

clean:
	rm -rf out/

define compile
	latexmk -lualatex --output-directory=out/${1} abschnitte/${1}/*
endef

@PHPirates
Copy link
Collaborator

Thanks, now it makes sense to me. I don't see any reason not to use LaTeX run configurations. If you do, then I think we can fix this: when resolving files, we need to check the working directory of the run configuration. What was your reason to not use run configs?

(I don't know from memory if we support putting a wildcard abschnitte/Bewerbung/* as main file in the run config, but if not that is easily fixed)

@PHPirates PHPirates removed the more-info-needed More information is needed from the person filing the issue. label Nov 5, 2024
@PHPirates PHPirates changed the title "File 'path/file' not found" Resolving file references should take working directory of run configuration into account Nov 5, 2024
@MartinX3
Copy link
Author

MartinX3 commented Nov 7, 2024

Thank you for your help!

Do you mean the IntelliJ Run Configurations?
The google results are not clear for me.

But if you mean them wouldn't that mean the project depends on IntelliJ and your plugin then instead of being buildable on any PC and also the GitHub CI?

@PHPirates
Copy link
Collaborator

Yes: https://www.jetbrains.com/help/idea/run-debug-configuration.html
No, because anyone will use their favourite IDE to compile the document. Some may use a VSCode run configuration, or prefer to run with lualatex directly, maybe they prefer a different output directory, or maybe they want to use some other build system such as bazel, or maybe they use Windows so can't run a Makefile at all.

My point is, if you use other tools outside of IntelliJ then there are some things (like this issue) that we cannot support automatically from TeXiFy. That means you need to do some manual configuration, in this case: right-click the job-application directory and select 'mark as Sources root'
(I just tried that myself and it doesn't seem to work, so that's a different bug)

@MartinX3
Copy link
Author

MartinX3 commented Nov 7, 2024

Ahhh, thank you.

In my case I use the Makefile plugin to use its targets as run configurations.
(And so the CI can use the targets, too)

So if the feature to set the root directory it would work?

How people usually do organize their LaTeX projects?
Since also ../../.. doesn't work as a path.
(It's also red in the IDE)

@PHPirates
Copy link
Collaborator

PHPirates commented Nov 7, 2024

Usually looks like this: https://hannah-sten.github.io/TeXiFy-IDEA/troubleshooting.html#what-should-my-document-structure-look-like but then with included files in subdirectories as you have
So there may be multiple main files, but I would place them usually top-level and not in a subdirectory, so that other people running it cannot be confused what the working directory should be. However, there is not really a standard, your structure is completely fine, just need to mark the top level directory as source root.

@MartinX3
Copy link
Author

Thank you for your help.
So I wait until this bug is fixed which makes the marking of the top level as source root useless at the moment.

@PHPirates
Copy link
Collaborator

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

No branches or pull requests

2 participants