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

No such file or directory error when using shell escape and tex files in subdirectory #1149

Open
derchr opened this issue Feb 14, 2024 · 3 comments · May be fixed by #1151
Open

No such file or directory error when using shell escape and tex files in subdirectory #1149

derchr opened this issue Feb 14, 2024 · 3 comments · May be fixed by #1151

Comments

@derchr
Copy link

derchr commented Feb 14, 2024

Hello,
I'm facing an issue where a temporary file cannot be written during the compilation process when shell-escape is enabled to use the minted package.
I suspect the issue comes from the fact, that some of my source files lie in a subdirectory of the root src directory and the file creation in the tmp directory fails as the subdirectory is not explicitly created before writing the file.

If this is the case, a simple call to the std::fs::create_dir_all function should be able to create the subdirectories before trying to write files into them.

Full error log
warning: lineno.sty:296: Invalid UTF-8 byte or sequence at line 296 replaced by U+FFFD.
warning: open of input /dev/null.tex failed
caused by: access to the path `/dev/null.tex` is forbidden
warning: open of input /dev/null.tex failed
caused by: access to the path `/dev/null.tex` is forbidden
error: failed to create file `/tmp/.tmpdFJUpo/chapters/results.aux`
caused by: No such file or directory (os error 2)
error: failed to execute the shell-escape command "uname -s > "doc.w18"": execution of the request failed
error: ifplatform.sty:92: Package catchfile Error: File `doc.w18' not found.

See the catchfile package documentation for explanation.
Type  H <return>  for immediate help
error: halted on potentially-recoverable error as specified
@derchr
Copy link
Author

derchr commented Feb 14, 2024

I was actually able to fix the bug applying this patch:

diff --git a/src/driver.rs b/src/driver.rs
index 2911885b..de1db00b 100644
--- a/src/driver.rs
+++ b/src/driver.rs
@@ -704,6 +704,8 @@ impl DriverHooks for BridgeState {
                 }
 
                 let real_path = work.root().join(name);
+                let prefix = real_path.parent().unwrap();
+                std::fs::create_dir_all(prefix).unwrap();
                 let mut f = File::create(&real_path).map_err(|e| {
                     tt_error!(status, "failed to create file `{}`", real_path.display(); e.into());
                     SystemRequestError::Failed

@pkgw
Copy link
Collaborator

pkgw commented Feb 15, 2024

@derchr Thank you for digging into this! Would you be in a position to submit this patch as a pull request?

@derchr
Copy link
Author

derchr commented Feb 15, 2024

@derchr Thank you for digging into this! Would you be in a position to submit this patch as a pull request?

Yes, I can create a pull request. However, I do not have the knowledge of the code base to evaluate if this is the right fix to do, it just seemed to work in my case.

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 a pull request may close this issue.

2 participants