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

Stderr fix #1606

Merged
merged 19 commits into from
Jan 28, 2025
Merged

Stderr fix #1606

merged 19 commits into from
Jan 28, 2025

Conversation

rpspringuel
Copy link
Contributor

I'm not sure why we never considered this for a merge. It looks fully ready to me so I'm putting it here for comments.

rpspringuel and others added 19 commits March 13, 2021 13:40
Some errors for gregorio print to stderr but do not write to glog.  This leads to the error being lost when autocompiling, so we add a redirect which will capture the stderr output and put it in glog.
When compiling gabc files, tmp-gre will be created in the cwd and gtex and glog files will be written there.  This allows for compilation of gabc files which are outside the current tree and should allow for compilation of tex files from outside outside of the project folder.
Vary filename for scores in scribus render frames
@rpspringuel
Copy link
Contributor Author

Barring objections I'll merge this on Monday.

@eschwab
Copy link
Contributor

eschwab commented Jan 26, 2025

I was hoping to test it, but cannot get time for that until Tuesday. The code looks fine though.

@rpspringuel
Copy link
Contributor Author

I can wait until Tuesday. Please do review it if you have the time.

@eschwab eschwab self-requested a review January 28, 2025 03:21
@eschwab
Copy link
Contributor

eschwab commented Jan 28, 2025

Had a chance to look at this today. Works as expected.

@rpspringuel rpspringuel merged commit d7f83e3 into gregorio-project:develop Jan 28, 2025
@@ -798,8 +870,8 @@ local function compile_gabc(gabc_file, gtex_file, glog_file, allow_deprecated)
extra_args = extra_args..' -D'
end

local cmd = string.format('%s %s -W -o %s -l %s "%s"', gregorio_exe(),
extra_args, gtex_file, glog_file, gabc_file)
local cmd = string.format('%s %s -W -o %s -l %s "%s" 2> %s', gregorio_exe(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line might be causing an error for me sometimes. The error looks like this:

(.../tex/latex/latexconfig
/epstopdf-sys.cfg))ignored arguments: 2> tmp-gre/alma-6_0_0.glog
Usage: gregorio [OPTION]... [-s | INPUT_FILE]
Try 'gregorio --help' for more information.
Proceeding anyway...

(.../tmp-gre/alma-6_0_0.gtex

Sometimes it actually causes the run to pause and sometimes it finishes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's supposed to be file redirection to make sure that output to stderr gets recorded in the glog file (makes debugging easier). Not sure why it would be rendering it as "ignored arguments". Do we need to quote the filename of the glog file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found the problem: if --shell-escape is not given, but gregorio is listed in shell_escape_commands in texmf.cnf, then 2> gets interpreted as an ordinary argument. Gregorio will output a warning about extra arguments, which is harmless, but the glog file will be empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gregorio will always be in the listed shell_escape_commands for TeX Live (and I think MiKTeX too). I'll ask the TeX Live people about this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, which is a good thing, but presumably the restriction on redirects is a security measure. (For example, they certainly wouldn't want to allow os.execute("gregorio | rm -rf *").)

Perhaps an alternative is to make gregorio itself write the .glog file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It already can. That's what the -l option is all about. There are just some errors that the -l option doesn't capture. See #1541.

The point of the redirection is to try and capture those errors too, as they sometimes are needed to diagnose what's going wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, so ultimately this error message I'm seeing is unintended but mostly harmless. I've verified that if gregorio outputs an error, it does appear in the glog.

I mentioned above that sometimes TeX was stopping, and I am now guessing that it was for some other reason (still don't know what).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So long as it's harmless, then I see no need to change things. If it works as expected with the --shell-escape option, then the error messages can be captured when needed even if normal operation doesn't capture them because of the security measures.

@rpspringuel rpspringuel deleted the stderr-fix branch February 6, 2025 00:55
@rpspringuel rpspringuel mentioned this pull request Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants