General"Can't write on file" error, but this isn't a ../ reference: why?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
henrylaw
Posts: 2
Joined: Fri Mar 30, 2018 5:41 pm

"Can't write on file" error, but this isn't a ../ reference: why?

Post by henrylaw »

pdfTeX 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian)
kpathsea version 6.2.1

My directory structure is as follows:

Code: Select all

.                       all the main .tex files
./graphics              image files
./pod                   machine-generated .tex files
./pdf                   output
The include statements in the master document (acsd.tex) are of the form

Code: Select all

%\chapter{General overview}
\include{acsd-010} 
%\chapter{The network}
\include{acsd-020}
... etc; and later
% Include from-POD documentation
\include{pod/ssmcCmd}
\include{pod/ssmcConsole}
... etc
From the root directory I issue the command pdflatex -output-directory ./pdf acsd.tex

And the formatter run crashes at the first include for the subdirectory, i.e. \include{pod/ssmcCmd}, with the message

Code: Select all

I can't write on file `pod/ssmcCmd.aux'.
\@include ...\immediate \openout \@partaux #1.aux 
                                                  \immediate \write \@partau...
l.94 \include{pod/ssmcCmd}
Now I understand the FAQ "LaTeX won’t include from other directories" but that applies to include statements referring to directories up the tree (\include{../bar/xyz.tex}) but I'm not trying to do that, and yet the error I have looks like the same thing.

What am I doing wrong?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

henrylaw
Posts: 2
Joined: Fri Mar 30, 2018 5:41 pm

"Can't write on file" error, but this isn't a ../ reference: why?

Post by henrylaw »

I continued fiddling about (as you do) and discovered that if I omit the -output-directory flag then it all works fine. Can it be that in order to implement the -output-directory flag the code changes to that directory, after which the imbed of ./foo/bar becomes ../foo/bar and fails because of the limitation?

Would this count as a bug? It's certainly counter-intuitive.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

"Can't write on file" error, but this isn't a ../ reference: why?

Post by Stefan Kottwitz »

Hi,

and welcome to the forum!

I read your posts and thought about it. I just could not test as I'm traveling. Good to read that it probably works fine without the -output-directory flag!

Your TeX version is old though, of 2015. I know, stable Debian is behind the official TeX Live releases, though that's ok for common TeX documents without new features. TeX Live 2018 is in the testing phase and will be released in some weeks, I hope. Perhaps (after release) consider a TeX install from tug.org/texlive instead of from Debian repositories, it should work fine. I do that with Debian (servers) and Ubuntu (desktop, based on Debian).

Stefan
LaTeX.org admin
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

"Can't write on file" error, but this isn't a ../ reference: why?

Post by rais »

henrylaw wrote:Can it be that in order to implement the -output-directory flag the code changes to that directory, after which the imbed of ./foo/bar becomes ../foo/bar and fails because of the limitation?
Not quite. Whenever you \include something, a partial aux file is opened for writing and when you change your output directory, this will be opened under that directory. However, this routine does not create missing folders on the fly...
In other words: your \include{foo/bar} tells LaTeX to create .pdf/foo/bar.aux which fails, because you did not create a subfolder foo in ./pdf.

Another possibility would be to use \input instead of \include, because \input just reads the file.

KR
Rainer
Post Reply