Discussion:
[PATCH] Check exit code of LaTeX process in LaTeX::run
Scott Kostyshak
2014-09-12 12:53:00 UTC
Permalink
Systemcall::startscript returns the exit code of the LaTeX command
that is run, but the return value was not being checked by
LaTeX::run. It is now checked and if the exit code is non-zero,
it is returned immediately.

At a higher level, if the LaTeX command returns a non-zero
exit code, in the GUI a message such as "Error while exporting
format: PDF (LuaTeX)" is given instead of "Successful preview
of format: PDF (LuaTeX)" followed by the attempt to open an
incomplete/missing .pdf file.

When run on the commandline, lyx -e lualatex example.lyx now
gives "Error: LaTeX failed" and a non-zero exit code where before
it gave a zero exit code.

Any thoughts? See my other email for a use case.

Scott
Scott Kostyshak
2014-09-13 15:22:34 UTC
Permalink
Post by Scott Kostyshak
Systemcall::startscript returns the exit code of the LaTeX command
that is run, but the return value was not being checked by
LaTeX::run. It is now checked and if the exit code is non-zero,
it is returned immediately.
At a higher level, if the LaTeX command returns a non-zero
exit code, in the GUI a message such as "Error while exporting
format: PDF (LuaTeX)" is given instead of "Successful preview
of format: PDF (LuaTeX)" followed by the attempt to open an
incomplete/missing .pdf file.
When run on the commandline, lyx -e lualatex example.lyx now
gives "Error: LaTeX failed" and a non-zero exit code where before
it gave a zero exit code.
Any thoughts? See my other email for a use case.
Scott
Another use case, that I can reproduce with TeX Live 2013 and 2014 is:
1. Go to File > New From Template and select ACM-sigplan.lyx
(2.) You may need to follow the instructions to install the SIGPLAN LaTeX class.
3. View with pdflatex.

What happens is that LyX will export the file and say it was
successful. A file is actually produced and so the view seems to work.
But actually the terminal shows <<'pdflatex "newfile1.tex"' finished
with exit code 1>>.

With this patch, LyX correctly says that the export failed.

Actually, now I realize that this is related to #2757 and has the same
potential to annoy users that fixing #2757 did. In fact, assuming
bibtex exits with error, this commit would also break compilation for
users.

Scott
Kornel Benko
2014-09-13 16:56:15 UTC
Permalink
Post by Scott Kostyshak
Post by Scott Kostyshak
Systemcall::startscript returns the exit code of the LaTeX command
that is run, but the return value was not being checked by
LaTeX::run. It is now checked and if the exit code is non-zero,
it is returned immediately.
At a higher level, if the LaTeX command returns a non-zero
exit code, in the GUI a message such as "Error while exporting
format: PDF (LuaTeX)" is given instead of "Successful preview
of format: PDF (LuaTeX)" followed by the attempt to open an
incomplete/missing .pdf file.
When run on the commandline, lyx -e lualatex example.lyx now
gives "Error: LaTeX failed" and a non-zero exit code where before
it gave a zero exit code.
Any thoughts? See my other email for a use case.
Scott
1. Go to File > New From Template and select ACM-sigplan.lyx
(2.) You may need to follow the instructions to install the SIGPLAN LaTeX class.
3. View with pdflatex.
What happens is that LyX will export the file and say it was
successful. A file is actually produced and so the view seems to work.
But actually the terminal shows <<'pdflatex "newfile1.tex"' finished
with exit code 1>>.
With this patch, LyX correctly says that the export failed.
Actually, now I realize that this is related to #2757 and has the same
potential to annoy users that fixing #2757 did. In fact, assuming
bibtex exits with error, this commit would also break compilation for
users.
IMHO, if bibtex exits with errors, the compilation _is_ not OK, so
the users should get appropriate error message (and break compilation).
Post by Scott Kostyshak
Scott
Kornel
Scott Kostyshak
2014-09-15 18:48:32 UTC
Permalink
Post by Kornel Benko
Post by Scott Kostyshak
Post by Scott Kostyshak
Systemcall::startscript returns the exit code of the LaTeX command
that is run, but the return value was not being checked by
LaTeX::run. It is now checked and if the exit code is non-zero,
it is returned immediately.
At a higher level, if the LaTeX command returns a non-zero
exit code, in the GUI a message such as "Error while exporting
format: PDF (LuaTeX)" is given instead of "Successful preview
of format: PDF (LuaTeX)" followed by the attempt to open an
incomplete/missing .pdf file.
When run on the commandline, lyx -e lualatex example.lyx now
gives "Error: LaTeX failed" and a non-zero exit code where before
it gave a zero exit code.
Any thoughts? See my other email for a use case.
Scott
1. Go to File > New From Template and select ACM-sigplan.lyx
(2.) You may need to follow the instructions to install the SIGPLAN LaTeX class.
3. View with pdflatex.
What happens is that LyX will export the file and say it was
successful. A file is actually produced and so the view seems to work.
But actually the terminal shows <<'pdflatex "newfile1.tex"' finished
with exit code 1>>.
With this patch, LyX correctly says that the export failed.
Actually, now I realize that this is related to #2757 and has the same
potential to annoy users that fixing #2757 did. In fact, assuming
bibtex exits with error, this commit would also break compilation for
users.
IMHO, if bibtex exits with errors, the compilation _is_ not OK, so
the users should get appropriate error message (and break compilation).
Six out of seven days I wake up and I agree. But one day a week I
think about the LyX user who upgrades and the document stops
compiling. It's a regression from the point of view of the user.

I really hope others give their thoughts on this, as well as #2757. We
need to do something but it's not clear to me what to do.

Scott
Kornel Benko
2014-09-15 19:22:42 UTC
Permalink
Post by Scott Kostyshak
Post by Kornel Benko
Post by Scott Kostyshak
Post by Scott Kostyshak
Systemcall::startscript returns the exit code of the LaTeX command
that is run, but the return value was not being checked by
LaTeX::run. It is now checked and if the exit code is non-zero,
it is returned immediately.
At a higher level, if the LaTeX command returns a non-zero
exit code, in the GUI a message such as "Error while exporting
format: PDF (LuaTeX)" is given instead of "Successful preview
of format: PDF (LuaTeX)" followed by the attempt to open an
incomplete/missing .pdf file.
When run on the commandline, lyx -e lualatex example.lyx now
gives "Error: LaTeX failed" and a non-zero exit code where before
it gave a zero exit code.
Any thoughts? See my other email for a use case.
Scott
1. Go to File > New From Template and select ACM-sigplan.lyx
(2.) You may need to follow the instructions to install the SIGPLAN LaTeX class.
3. View with pdflatex.
What happens is that LyX will export the file and say it was
successful. A file is actually produced and so the view seems to work.
But actually the terminal shows <<'pdflatex "newfile1.tex"' finished
with exit code 1>>.
With this patch, LyX correctly says that the export failed.
Actually, now I realize that this is related to #2757 and has the same
potential to annoy users that fixing #2757 did. In fact, assuming
bibtex exits with error, this commit would also break compilation for
users.
IMHO, if bibtex exits with errors, the compilation _is_ not OK, so
the users should get appropriate error message (and break compilation).
Six out of seven days I wake up and I agree. But one day a week I
think about the LyX user who upgrades and the document stops
compiling. It's a regression from the point of view of the user.
In this sense, if we correct some bad behaviour, it would be a regression too.
I am not ready to adopt this view :)
Post by Scott Kostyshak
I really hope others give their thoughts on this, as well as #2757. We
need to do something but it's not clear to me what to do.
Scott
Kornel
Scott Kostyshak
2014-09-17 13:06:00 UTC
Permalink
Post by Kornel Benko
Post by Scott Kostyshak
Post by Kornel Benko
IMHO, if bibtex exits with errors, the compilation _is_ not OK, so
the users should get appropriate error message (and break compilation).
Six out of seven days I wake up and I agree. But one day a week I
think about the LyX user who upgrades and the document stops
compiling. It's a regression from the point of view of the user.
In this sense, if we correct some bad behaviour, it would be a regression too.
I am not ready to adopt this view :)
For discussion on a very similar topic (possibly a specific case of
the fix proposed here), see this discussion:
https://www.mail-archive.com/lyx-***@lists.lyx.org/msg183570.html
We received a lot of reports that "LyX doesn't compile my document
anymore". Vincent made the reasonable decision to suggest reverting
the bug fix and a couple of other developers agreed.

Are you opposed to the approach suggested there, which is to give a
warning in the next major release and in the warning state "in the
next version this will be an error and your document will not
compile"?

Scott
Kornel Benko
2014-09-17 14:02:47 UTC
Permalink
Post by Scott Kostyshak
Post by Kornel Benko
Post by Scott Kostyshak
Post by Kornel Benko
IMHO, if bibtex exits with errors, the compilation _is_ not OK, so
the users should get appropriate error message (and break compilation).
Six out of seven days I wake up and I agree. But one day a week I
think about the LyX user who upgrades and the document stops
compiling. It's a regression from the point of view of the user.
In this sense, if we correct some bad behaviour, it would be a regression too.
I am not ready to adopt this view :)
For discussion on a very similar topic (possibly a specific case of
We received a lot of reports that "LyX doesn't compile my document
anymore". Vincent made the reasonable decision to suggest reverting
the bug fix and a couple of other developers agreed.
I understood it that way, that the fix were postponed only.
Quoting Vincent:
"Then, if we succeed to quickly release the next major release we can
error out on BibTeX errors as we do now."
May I understand version 2.2 as major?
Post by Scott Kostyshak
Are you opposed to the approach suggested there, which is to give a
warning in the next major release and in the warning state "in the
next version this will be an error and your document will not
compile"?
I vote for error out, if there is error in compiling.

Maybe some document option
Output -> Default Output Format:
Output -> Synchronize with Output
new Output -> Ignore errors if export file created
Output Options -> XHTML Output Options


or new
Bibliography -> Bibliography generation -> Ignore errors
Post by Scott Kostyshak
Scott
Kornel
Scott Kostyshak
2014-09-17 14:30:01 UTC
Permalink
Post by Kornel Benko
Post by Scott Kostyshak
Post by Kornel Benko
Post by Scott Kostyshak
Post by Kornel Benko
IMHO, if bibtex exits with errors, the compilation _is_ not OK, so
the users should get appropriate error message (and break compilation).
Six out of seven days I wake up and I agree. But one day a week I
think about the LyX user who upgrades and the document stops
compiling. It's a regression from the point of view of the user.
In this sense, if we correct some bad behaviour, it would be a regression too.
I am not ready to adopt this view :)
For discussion on a very similar topic (possibly a specific case of
We received a lot of reports that "LyX doesn't compile my document
anymore". Vincent made the reasonable decision to suggest reverting
the bug fix and a couple of other developers agreed.
I understood it that way, that the fix were postponed only.
"Then, if we succeed to quickly release the next major release we can
error out on BibTeX errors as we do now."
Well you do not quote the part right before that which says
"as soon as possible we replace the error by a warning when we detect
a BibTeX error stating that in the future this will lead to an error."
- I interpret this to mean that first we need a released LyX version
with the warning. I also supposed that it was meant a major version.
Post by Kornel Benko
May I understand version 2.2 as major?
Yes.
Post by Kornel Benko
Post by Scott Kostyshak
Are you opposed to the approach suggested there, which is to give a
warning in the next major release and in the warning state "in the
next version this will be an error and your document will not
compile"?
I vote for error out, if there is error in compiling.
I'm fine with this. And from what I understand so is Jürgen. I'm also
now fine with the warning -> error approach.
Post by Kornel Benko
Maybe some document option
Output -> Synchronize with Output
new Output -> Ignore errors if export file created
Output Options -> XHTML Output Options
This is a good proposal and in fact I was fearing that if we do the
warning -> error approach users will request this feature anyway. If
we do decide to do warning -> error approach, we should decide now
whether to take a hard stance on "no we will not give you the option
to ignore errors in the future" or if we will consider it if enough
users request it.
Post by Kornel Benko
or new
Bibliography -> Bibliography generation -> Ignore errors
I would prefer your first suggestion above. Or a centralized place to
choose which errors to ignore. We could even add \nonstopmode to
ignore LaTeX errors. We could have a "do whatever it takes to give me
a PDF" mode.

ugh it is very painful to discuss helping users to avoid fixing errors
in their documents. But I guess many users would like it.

Scott
Richard Heck
2014-09-17 14:32:12 UTC
Permalink
Post by Scott Kostyshak
Post by Kornel Benko
Post by Scott Kostyshak
Post by Kornel Benko
Post by Scott Kostyshak
Post by Kornel Benko
IMHO, if bibtex exits with errors, the compilation _is_ not OK, so
the users should get appropriate error message (and break compilation).
Six out of seven days I wake up and I agree. But one day a week I
think about the LyX user who upgrades and the document stops
compiling. It's a regression from the point of view of the user.
In this sense, if we correct some bad behaviour, it would be a regression too.
I am not ready to adopt this view :)
For discussion on a very similar topic (possibly a specific case of
We received a lot of reports that "LyX doesn't compile my document
anymore". Vincent made the reasonable decision to suggest reverting
the bug fix and a couple of other developers agreed.
I understood it that way, that the fix were postponed only.
"Then, if we succeed to quickly release the next major release we can
error out on BibTeX errors as we do now."
Well you do not quote the part right before that which says
"as soon as possible we replace the error by a warning when we detect
a BibTeX error stating that in the future this will lead to an error."
- I interpret this to mean that first we need a released LyX version
with the warning. I also supposed that it was meant a major version.
I think that meant we could do it in a minor version. Like the next one.
And I think it's a
good idea. Not issuing any kind of error here is wrong. The user thinks
everything went
well, and it did not.

Richard
Scott Kostyshak
2014-09-17 15:04:41 UTC
Permalink
Post by Scott Kostyshak
Post by Kornel Benko
Post by Scott Kostyshak
Am Montag, 15. September 2014 um 14:48:32, schrieb Scott Kostyshak
Post by Scott Kostyshak
Post by Kornel Benko
IMHO, if bibtex exits with errors, the compilation _is_ not OK, so
the users should get appropriate error message (and break compilation).
Six out of seven days I wake up and I agree. But one day a week I
think about the LyX user who upgrades and the document stops
compiling. It's a regression from the point of view of the user.
In this sense, if we correct some bad behaviour, it would be a regression too.
I am not ready to adopt this view :)
For discussion on a very similar topic (possibly a specific case of
We received a lot of reports that "LyX doesn't compile my document
anymore". Vincent made the reasonable decision to suggest reverting
the bug fix and a couple of other developers agreed.
I understood it that way, that the fix were postponed only.
"Then, if we succeed to quickly release the next major release we can
error out on BibTeX errors as we do now."
Well you do not quote the part right before that which says
"as soon as possible we replace the error by a warning when we detect
a BibTeX error stating that in the future this will lead to an error."
- I interpret this to mean that first we need a released LyX version
with the warning. I also supposed that it was meant a major version.
I think that meant we could do it in a minor version. Like the next one. And
I think it's a
good idea.
I'm fine with this but only because I'm fine with not going through
the warning phase. I think there are very few LyX users that install
consecutive minor versions. Out of the 10 or so people I know running
LyX, the median LyX version is probably 2.0.5. Also, anyone on a Linux
distribution installing from their repos will have a few minor
versions skipped.
Not issuing any kind of error here is wrong. The user thinks
everything went
well, and it did not.
Agreed.

Scott
Richard Heck
2014-09-17 17:49:20 UTC
Permalink
Post by Scott Kostyshak
Post by Scott Kostyshak
Am Mittwoch, 17. September 2014 um 09:06:00, schrieb Scott Kostyshak
Post by Scott Kostyshak
Am Montag, 15. September 2014 um 14:48:32, schrieb Scott Kostyshak
Post by Scott Kostyshak
Post by Kornel Benko
IMHO, if bibtex exits with errors, the compilation _is_ not OK, so
the users should get appropriate error message (and break compilation).
Six out of seven days I wake up and I agree. But one day a week I
think about the LyX user who upgrades and the document stops
compiling. It's a regression from the point of view of the user.
In this sense, if we correct some bad behaviour, it would be a regression too.
I am not ready to adopt this view :)
For discussion on a very similar topic (possibly a specific case of
We received a lot of reports that "LyX doesn't compile my document
anymore". Vincent made the reasonable decision to suggest reverting
the bug fix and a couple of other developers agreed.
I understood it that way, that the fix were postponed only.
"Then, if we succeed to quickly release the next major
release we can
error out on BibTeX errors as we do now."
Well you do not quote the part right before that which says
"as soon as possible we replace the error by a warning when we detect
a BibTeX error stating that in the future this will lead to an error."
- I interpret this to mean that first we need a released LyX version
with the warning. I also supposed that it was meant a major version.
I think that meant we could do it in a minor version. Like the next one. And
I think it's a good idea.
I'm fine with this but only because I'm fine with not going through
the warning phase. I think there are very few LyX users that install
consecutive minor versions. Out of the 10 or so people I know running
LyX, the median LyX version is probably 2.0.5. Also, anyone on a Linux
distribution installing from their repos will have a few minor
versions skipped.
I guess that depends upon the distro: http://oswatershed.org/pkg/lyx.

So I officially suggest that we do the following: For 2.1.3, we add the
warning;
for 2.2.0, we add the error.

Richard
Kornel Benko
2014-09-17 18:33:02 UTC
Permalink
Post by Richard Heck
Post by Scott Kostyshak
Post by Scott Kostyshak
Am Mittwoch, 17. September 2014 um 09:06:00, schrieb Scott Kostyshak
Post by Scott Kostyshak
Am Montag, 15. September 2014 um 14:48:32, schrieb Scott Kostyshak
Post by Scott Kostyshak
Post by Kornel Benko
IMHO, if bibtex exits with errors, the compilation _is_ not OK, so
the users should get appropriate error message (and break compilation).
Six out of seven days I wake up and I agree. But one day a week I
think about the LyX user who upgrades and the document stops
compiling. It's a regression from the point of view of the user.
In this sense, if we correct some bad behaviour, it would be a
regression too.
I am not ready to adopt this view :)
For discussion on a very similar topic (possibly a specific case of
We received a lot of reports that "LyX doesn't compile my document
anymore". Vincent made the reasonable decision to suggest reverting
the bug fix and a couple of other developers agreed.
I understood it that way, that the fix were postponed only.
"Then, if we succeed to quickly release the next major
release we can
error out on BibTeX errors as we do now."
Well you do not quote the part right before that which says
"as soon as possible we replace the error by a warning when we detect
a BibTeX error stating that in the future this will lead to an error."
- I interpret this to mean that first we need a released LyX version
with the warning. I also supposed that it was meant a major version.
I think that meant we could do it in a minor version. Like the next one. And
I think it's a good idea.
I'm fine with this but only because I'm fine with not going through
the warning phase. I think there are very few LyX users that install
consecutive minor versions. Out of the 10 or so people I know running
LyX, the median LyX version is probably 2.0.5. Also, anyone on a Linux
distribution installing from their repos will have a few minor
versions skipped.
I guess that depends upon the distro: http://oswatershed.org/pkg/lyx.
So I officially suggest that we do the following: For 2.1.3, we add the
warning;
for 2.2.0, we add the error.
+1
Post by Richard Heck
Richard
Kornel
Scott Kostyshak
2014-09-17 19:02:28 UTC
Permalink
Post by Richard Heck
Post by Scott Kostyshak
Post by Scott Kostyshak
Am Mittwoch, 17. September 2014 um 09:06:00, schrieb Scott Kostyshak
Post by Scott Kostyshak
Am Montag, 15. September 2014 um 14:48:32, schrieb Scott Kostyshak
Post by Scott Kostyshak
Post by Kornel Benko
IMHO, if bibtex exits with errors, the compilation _is_ not OK, so
the users should get appropriate error message (and break compilation).
Six out of seven days I wake up and I agree. But one day a week I
think about the LyX user who upgrades and the document stops
compiling. It's a regression from the point of view of the user.
In this sense, if we correct some bad behaviour, it would be a regression too.
I am not ready to adopt this view :)
For discussion on a very similar topic (possibly a specific case of
We received a lot of reports that "LyX doesn't compile my document
anymore". Vincent made the reasonable decision to suggest reverting
the bug fix and a couple of other developers agreed.
I understood it that way, that the fix were postponed only.
"Then, if we succeed to quickly release the next major
release we can
error out on BibTeX errors as we do now."
Well you do not quote the part right before that which says
"as soon as possible we replace the error by a warning when we detect
a BibTeX error stating that in the future this will lead to an error."
- I interpret this to mean that first we need a released LyX version
with the warning. I also supposed that it was meant a major version.
I think that meant we could do it in a minor version. Like the next one. And
I think it's a good idea.
I'm fine with this but only because I'm fine with not going through
the warning phase. I think there are very few LyX users that install
consecutive minor versions. Out of the 10 or so people I know running
LyX, the median LyX version is probably 2.0.5. Also, anyone on a Linux
distribution installing from their repos will have a few minor
versions skipped.
I guess that depends upon the distro: http://oswatershed.org/pkg/lyx.
That is a great resource. Thank you!
Post by Richard Heck
So I officially suggest that we do the following: For 2.1.3, we add the
warning;
for 2.2.0, we add the error.
Sounds good.
Are there any ideas for the message? Without thinking much, I will throw out:

"xyz finished with an error. This was not previously reported in LyX
so compilation is allowed to continue, but starting with LyX 2.2.0
this warning message will become an error and compilation will stop so
that the user knows to fix the issue causing the error."

Scott
Richard Heck
2014-09-17 20:14:01 UTC
Permalink
Post by Scott Kostyshak
Are there any ideas for the message? Without thinking much, I will
throw out: "xyz finished with an error. This was not previously
reported in LyX so compilation is allowed to continue, but starting
with LyX 2.2.0 this warning message will become an error and
compilation will stop so that the user knows to fix the issue causing
the error."
Minor tweaking:

The external program
XYZ [[ probably on its own line, since these commands can be long ]]
finished with an error. Compilation will be [[ has been ?? I guess this
depends when the warning is issued. ]] allowed to continue, but starting
with LyX 2.2.0 this warning message will become an error and compilation
will stop.

I don't think we need to explain in the dialog why that is. Though we
could add something like: We suggest you find the cause of the error.

A few questions: Can this only happen during compilation? Or could it
happen during other sorts of export? Should that word be changed? Could
it, in particular, happen during compilation of instant preview? I don't
use that, but I can imagine it getting extremely annoying in this case
to get that message, especially if it were caused by something in the
preamble that was included in every single case. So, if that is an
issue, perhaps we should disable the error for preview.

Richard
Scott Kostyshak
2014-09-17 20:41:06 UTC
Permalink
Post by Richard Heck
Post by Scott Kostyshak
Are there any ideas for the message? Without thinking much, I will throw
out: "xyz finished with an error. This was not previously reported in LyX so
compilation is allowed to continue, but starting with LyX 2.2.0 this warning
message will become an error and compilation will stop so that the user
knows to fix the issue causing the error."
The external program
XYZ [[ probably on its own line, since these commands can be long ]]
finished with an error. Compilation will be [[ has been ?? I guess this
depends when the warning is issued. ]] allowed to continue, but starting
with LyX 2.2.0 this warning message will become an error and compilation
will stop.
I don't think we need to explain in the dialog why that is. Though we could
add something like: We suggest you find the cause of the error.
Sounds good.
Post by Richard Heck
A few questions: Can this only happen during compilation? Or could it happen
during other sorts of export? Should that word be changed? Could it, in
particular, happen during compilation of instant preview? I don't use that,
but I can imagine it getting extremely annoying in this case to get that
message, especially if it were caused by something in the preamble that was
included in every single case. So, if that is an issue, perhaps we should
disable the error for preview.
Good point. I will test this.

Scott

Continue reading on narkive:
Search results for '[PATCH] Check exit code of LaTeX process in LaTeX::run' (Questions and Answers)
9
replies
How do you execute a file in Unix? I was told #!/bin/sh, but where is this used.?
started 2007-03-16 16:15:32 UTC
programming & design
Loading...