-
Notifications
You must be signed in to change notification settings - Fork 127
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
reducing dependency on shell escape #271
Comments
It seems that in restricted write18, redirection With \documentclass{article}
\usepackage{shellesc}
\begin{document}
\ShellEscape{pygmentize -S default -f latex -P commandprefix=PYGdefault > ./default.pygstyle}
\end{document} This can be further simplified to From the doc of
Of course, one can write a wrapper python script to support syntax of
|
All the pygmentize commands could be switched to use If cleanup isn't an issue, then So actually using |
Thanks. I'd started adjusting \DeleteFile, \TestAppExist and friends but missed the redirect, from the comments it seems that it should be feasible; I will probably try again and report back here but probably not this week. |
@gpoore @davidcarlisle |
@muzimuzhi You're right about |
On my own server I can add pygmentize to the restricted shell list (in fact I have done so) but if I were to try to get it added by default so minted could be used by normal setup without shell escape then I'd have to answer this question which has been in the default config for years
So if we were to have a wrapper script that added -o perhaps it could also simply disable some of the options, I note even
so pygmentize would not be allowed in the default texlive list as is. This wouldn't be unusual: epstopdf and mpost have @gpoore wrote
Yes I already do some of that (for other packages) although I try to avoid it too much as applying regex replace to incoming documents has a potential to mess things up and confuse the user greatly:-) But while my immediate concern is a server setup I think this would be useful in general. |
@davidcarlisle Thanks for pointing out the reason pygmentize isn't on the restricted shell list! I've actually been thinking about a wrapper for pygmentize to add some additional functionality (mostly simple things like autogobble that are trivial in Python but difficult in LaTeX--this currently involves its own \ShellEsc, increasing complexity and overhead). If a wrapper could also eliminate the need for |
(a little off-topic) One concern, will texlive accept to add a new command to |
@muzimuzhi well I can ask Karl:-) epstopdf relies on gs and (on most platforms) that isn't part of texlive but needs to be in installed in the system. texosquery is in the list and needs java, so I don't think it is impossible to get this added if it is sufficiently restricted. |
Update: |
minted v3.0.0beta1, which is designed to be compatible with restricted shell escape, is now available. If you would like to experiment with the beta version, installation instructions are here and the CHANGELOG includes details about new features (the PDF documentation won't be fully updated until the final v3 release). Otherwise, the final v3 release should be available sometime in June. |
I'm very excited about these developments, so I tried to experiment with v3. I tried the following test file:
However I get the following error:
Any idea what I'm doing wrong? My |
@samcarter It should work now with 36a0a5f. There was a bug in timestamp parsing. |
@gpoore Thanks a lot! This solves the problem! |
I have tried the following example with minted V3 and \documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{minted}
\begin{document}
Here are some small tests for the \texttt{minted} package.
\begin{minted}[mathescape,
linenos,
numbersep=5pt,
gobble=2,
frame=lines,
framesep=2mm]{csharp}
string title = "This is a Unicode π in the sky"
/*
Defined as $\pi=\lim_{n\to\infty}\frac{P_n}{d}$ where $P$ is the perimeter
of an $n$-sided regular polygon circumscribing a
circle of diameter $d$.
*/
const double pi = 3.1415926535
\end{minted}
\end{document}
|
@romildo There's a warning message that the |
By If so, it is available at the command line: $ type latexminted
latexminted is /run/current-system/sw/bin/latexminted
$ echo $PATH
/home/romildo/.local/bin:/run/wrappers/bin:/home/romildo/.nix-profile/bin:/nix/profile/bin:/home/romildo/.local/state/nix/profile/bin:/etc/profiles/per-user/romildo/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin
$ latexminted --version
latexminted 0.1.0b1 (libraries: latex2pydata 0.2.0, pygments 2.17.2)
$ pdflatex --shell-escape minted-test
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/nixos.org) (preloaded format=pdflatex)
[...]
Package minted Warning: minted v3+ Python executable is not installed or is not
added to PATH; falling back to minted v2 (install executable, or switch to pac
kage minted2) on input line 215.
[...] |
@romildo Yes, I meant |
$ pdflatex --shell-escape minted-test
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/nixos.org) (preloaded format=pdflatex)
\write18 enabled.
entering extended mode
(./minted-test.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-02-20>
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/base/size10.clo))
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/base/inputenc.sty)
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/base/fontenc.sty) (/home/romildo/texmf/tex/latex/minted/minted.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/catchfile/catchfile.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/infwarerr/infwarerr.sty)
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/ltxcmds/ltxcmds.sty)
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/etexcmds/etexcmds.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/iftex/iftex.sty)))
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/etoolbox/etoolbox.sty)
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/framed/framed.sty) (/home/romildo/texmf/tex/latex/fvextra/fvextra.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/fancyvrb/fancyvrb.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/graphics/keyval.sty))
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/upquote/upquote.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/base/textcomp.sty))
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/lineno/lineno.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/kvoptions/kvoptions.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/kvsetkeys/kvsetkeys.sty))))
(/home/romildo/texmf/tex/latex/latex2pydata/latex2pydata.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/pdftexcmds/pdftexcmds.sty))
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/pgf/utilities/pgfkeys.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/pgf/utilities/pgfkeys.code.tex
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/pgf/utilities/pgfkeyslibraryfiltered.code.tex)))
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/pgfopts/pgfopts.sty)
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/tools/shellesc.sty)system returned with code 256
Package minted Warning: minted v3+ Python executable is not installed or is not
added to PATH; falling back to minted v2 (install executable, or switch to pac
kage minted2) on input line 215.
! LaTeX Error: File `minted2.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
! Undefined control sequence.
<recently read> \DeleteFile
l.215 \fi
?
! Emergency stop.
<recently read> \DeleteFile
l.215 \fi
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on minted-test.log.
$ ls -AlF
total 32
-rw-r--r-- 1 romildo romildo 98 mai 26 23:35 _3F29AA7400DFA670869ED2F056F07532.data.minted
-rw-r--r-- 1 romildo romildo 768 mai 26 23:35 _3F29AA7400DFA670869ED2F056F07532.errlog.minted
-rw-r--r-- 1 romildo romildo 158 mai 26 23:35 _3F29AA7400DFA670869ED2F056F07532.message.minted
-rw-r--r-- 1 romildo romildo 8430 mai 26 23:36 minted-test.log
-rw-r--r-- 1 romildo romildo 611 mai 26 17:14 minted-test.tex
-rw-r--r-- 1 romildo romildo 94 mai 26 10:03 test.tex
$ cat _3F29AA7400DFA670869ED2F056F07532.data.minted
{
"command": "config",
"jobname": "minted-test",
"timestamp": "20240526233553",
"cachedir": "",
}
$ cat _3F29AA7400DFA670869ED2F056F07532.errlog.minted
File "/nix/store/n3kmpcq4zwpjsmy7immsqz0d2sv8sg31-latexminted-0.1.0b1/lib/python3.11/site-packages/latexminted/cmdline.py", line 95, in main
data = load_data(md5=md5, messages=messages, timestamp=timestamp, command=cmdline_args.subparser_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/n3kmpcq4zwpjsmy7immsqz0d2sv8sg31-latexminted-0.1.0b1/lib/python3.11/site-packages/latexminted/load_data.py", line 26, in load_data
data_text = data_path.read_text()
^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/n3kmpcq4zwpjsmy7immsqz0d2sv8sg31-latexminted-0.1.0b1/lib/python3.11/site-packages/latexminted/restricted/_restricted_pathlib.py", line 203, in read_text
raise PathSecurityError(
$ cat _3F29AA7400DFA670869ED2F056F07532.message.minted
\def\minted@exec@error{%
\minted@error{Failed due to unexpected error (see \detokenize{"_3F29AA7400DFA670869ED2F056F07532.errlog.minted"} if it exists)}%
}% |
@romildo There's a conflict with the security features for restricted shell escape. This might be a conflict with the restriction that files be under the home directory, as resolved by Python's
to see what Python considers your home directory, and then see if your .tex file is under that. This restriction is technically a bit more restrictive than required by TeX Live, so it should be possible to relax somewhat if necessary. It's also possible that I can keep the restriction but need to try more than |
The .tex file is not under my home directory. That would be too much restrictive. $ python -c "import pathlib; print(pathlib.Path.home().resolve())"
/home/romildo
$ pwd
/alt/programming/latex/minted |
If I move the .tex file to a subdirectory of my home directory, it works. $ pwd
/home/romildo/tmp/minted
$ pdflatex --shell-escape minted-test
[...]
$ pdflatex --shell-escape minted-test
[...] |
But if I add the $ pwd
/home/romildo/tmp/minted
$ mkdir _build
$ pdflatex -output-directory=_build --shell-escape minted-test
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/nixos.org) (preloaded format=pdflatex)
\write18 enabled.
entering extended mode
(./minted-test.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-02-20>
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/base/size10.clo))
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/base/inputenc.sty)
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/base/fontenc.sty) (/home/romildo/texmf/tex/latex/minted/minted.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/catchfile/catchfile.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/infwarerr/infwarerr.sty)
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/ltxcmds/ltxcmds.sty)
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/etexcmds/etexcmds.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/iftex/iftex.sty)))
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/etoolbox/etoolbox.sty)
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/framed/framed.sty) (/home/romildo/texmf/tex/latex/fvextra/fvextra.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/fancyvrb/fancyvrb.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/graphics/keyval.sty))
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/upquote/upquote.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/base/textcomp.sty))
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/lineno/lineno.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/kvoptions/kvoptions.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/kvsetkeys/kvsetkeys.sty))))
(/home/romildo/texmf/tex/latex/latex2pydata/latex2pydata.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/pdftexcmds/pdftexcmds.sty))
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/pgf/utilities/pgfkeys.sty
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/pgf/utilities/pgfkeys.code.tex
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/generic/pgf/utilities/pgfkeyslibraryfiltered.code.tex)))
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/pgfopts/pgfopts.sty)
(/nix/store/x9crynqyh5ygrfzqbj4cd39dwabx4kk6-texlive-combined-2023-texmfdist/te
x/latex/tools/shellesc.sty)Traceback (most recent call last):
File "/nix/store/n3kmpcq4zwpjsmy7immsqz0d2sv8sg31-latexminted-0.1.0b1/bin/.latexminted-wrapped", line 9, in <module>
sys.exit(main())
^^^^^^
File "/nix/store/n3kmpcq4zwpjsmy7immsqz0d2sv8sg31-latexminted-0.1.0b1/lib/python3.11/site-packages/latexminted/cmdline.py", line 105, in main
config(**func_args)
TypeError: config() missing 1 required keyword-only argument: 'data'
system returned with code 256
Package minted Warning: minted v3+ Python executable is not installed or is not
added to PATH; falling back to minted v2 (install executable, or switch to pac
kage minted2) on input line 215.
! LaTeX Error: File `minted2.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
! Undefined control sequence.
<recently read> \DeleteFile
l.215 \fi
?
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.215 \fi
?
! Emergency stop.
...
l.215 \fi
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on _build/minted-test.log.
$ ls -AlF
total 8
drwxr-xr-x 2 romildo romildo 4096 mai 27 09:28 _build/
-rw-r--r-- 1 romildo romildo 611 mai 27 09:19 minted-test.tex
$ ls -AlF _build
total 16
-rw-r--r-- 1 romildo romildo 98 mai 27 09:28 _3F29AA7400DFA670869ED2F056F07532.data.minted
-rw-r--r-- 1 romildo romildo 8816 mai 27 09:28 minted-test.log
$ cat _build/_3F29AA7400DFA670869ED2F056F07532.data.minted
{
"command": "config",
"jobname": "minted-test",
"timestamp": "20240527092805",
"cachedir": "",
} |
@romildo I've just released |
Thanks. Now it works outside of the home directory. As I do not have texlive 2024 yet, I found that I have to explicitly set the environment variable |
@gpoore, with minted v3, using the minted library for tcolorbox gives an error. \tcbuselibrary{minted}
|
@romildo tcolorbox adds an option to minted. However, with minted v3, option handling is redesigned so this doesn't work. I'll need to open an issue at the tcolorbox repository to get this removed, and make any needed modifications in minted v3 to provide additional functionality. This relates to #281. |
@gpoore it seems that |
@romildo Do you have a specific example of |
@gpoore Here is an example of \documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{minted}
\begin{document}
\begin{minted}[frame=single, escapeinside=!!]{c}
// defining !\underline{pi}!:
const double !\underline{pi}! = 3.1415926535;
\end{minted}
\end{document} $ grep 'Package: minted' test.log
Package: minted 2024/06/11 v3.0.0beta5 Yet another Pygments shim for LaTeX |
@romildo It should work now with the latest commit. The Pygments lexer needed to be wrapped in |
@romildo The latest |
Thanks. I've informed the maintainer of |
@gpoore I am trying to run the latest version of latexminted on my NixOS system, but if fails: $ latexminted --version
Traceback (most recent call last):
File "/nix/store/fl4qqwhqgd0jhiwjkl2fhgjba49127f3-latexminted-0.1.0b9/lib/python3.12/site-packages/latexminted/restricted/_latex_config.py", line 440, in TEXMFOUTPUT
value = self._var_cache['TEXMFOUTPUT']
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'TEXMFOUTPUT'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/nix/store/fl4qqwhqgd0jhiwjkl2fhgjba49127f3-latexminted-0.1.0b9/bin/.latexminted-wrapped", line 6, in <module>
from latexminted.cmdline import main
File "/nix/store/fl4qqwhqgd0jhiwjkl2fhgjba49127f3-latexminted-0.1.0b9/lib/python3.12/site-packages/latexminted/cmdline.py", line 13, in <module>
from .restricted import os_environ
File "/nix/store/fl4qqwhqgd0jhiwjkl2fhgjba49127f3-latexminted-0.1.0b9/lib/python3.12/site-packages/latexminted/restricted/__init__.py", line 12, in <module>
from ._restricted_pathlib import RestrictedPath
File "/nix/store/fl4qqwhqgd0jhiwjkl2fhgjba49127f3-latexminted-0.1.0b9/lib/python3.12/site-packages/latexminted/restricted/_restricted_pathlib.py", line 25, in <module>
if latex_config.TEXMFOUTPUT:
^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/fl4qqwhqgd0jhiwjkl2fhgjba49127f3-latexminted-0.1.0b9/lib/python3.12/site-packages/latexminted/restricted/_latex_config.py", line 443, in TEXMFOUTPUT
if value is None and self.texlive_kpsewhich:
^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/fl4qqwhqgd0jhiwjkl2fhgjba49127f3-latexminted-0.1.0b9/lib/python3.12/site-packages/latexminted/restricted/_latex_config.py", line 199, in texlive_kpsewhich
self._init_tex_paths()
File "/nix/store/fl4qqwhqgd0jhiwjkl2fhgjba49127f3-latexminted-0.1.0b9/lib/python3.12/site-packages/latexminted/restricted/_latex_config.py", line 181, in _init_tex_paths
raise LatexConfigError(
latexminted.err.LatexConfigError: Expected environment variables SELFAUTOLOC and/or TEXSYSTEM were not found or had invalid values, so "kpsewhich" executable and/or MiKTeX "initexmf" executable could not be found
$ kpsewhich --version
kpathsea version 6.3.5
Copyright 2023 Karl Berry & Olaf Weber.
License LGPLv2.1+: GNU Lesser GPL version 2.1 or later <https://gnu.org/licenses/lgpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Any clues? |
@romildo I think you're a few versions behind. The current version is |
(Sorry for that. I had just booted into the wrong system.) It is still not working: $ latexminted --version
Traceback (most recent call last):
File "/nix/store/vrdb3rg0c3zdzzc06q7glp55qvp5swsz-python3.12-latexrestricted-0.4.0/lib/python3.12/site-packages/latexrestricted/_restricted_pathlib.py", line 647, in writable_file
return self._writable_file_cache[self.cache_key]
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: (<class 'latexrestricted._restricted_pathlib.ResolvedRestrictedPath'>, ResolvedRestrictedPath('/home/romildo/.latexminted_config'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/nix/store/fyvbk8dn2pwyk2rq0idvw3wvds7b25zg-latexminted-0.1.0b15/bin/.latexminted-wrapped", line 6, in <module>
from latexminted.cmdline import main
File "/nix/store/fyvbk8dn2pwyk2rq0idvw3wvds7b25zg-latexminted-0.1.0b15/lib/python3.12/site-packages/latexminted/cmdline.py", line 13, in <module>
from .restricted import os_environ
File "/nix/store/fyvbk8dn2pwyk2rq0idvw3wvds7b25zg-latexminted-0.1.0b15/lib/python3.12/site-packages/latexminted/restricted/__init__.py", line 13, in <module>
from ._latexminted_config import latexminted_config
File "/nix/store/fyvbk8dn2pwyk2rq0idvw3wvds7b25zg-latexminted-0.1.0b15/lib/python3.12/site-packages/latexminted/restricted/_latexminted_config.py", line 218, in <module>
latexminted_config = LatexMintedConfig()
^^^^^^^^^^^^^^^^^^^
File "/nix/store/fyvbk8dn2pwyk2rq0idvw3wvds7b25zg-latexminted-0.1.0b15/lib/python3.12/site-packages/latexminted/restricted/_latexminted_config.py", line 116, in __init__
self._load(LatexMintedConfigPath.home() / config_name)
File "/nix/store/fyvbk8dn2pwyk2rq0idvw3wvds7b25zg-latexminted-0.1.0b15/lib/python3.12/site-packages/latexminted/restricted/_latexminted_config.py", line 140, in _load
data_str = path.read_text(encoding='utf-8-sig')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/vrdb3rg0c3zdzzc06q7glp55qvp5swsz-python3.12-latexrestricted-0.4.0/lib/python3.12/site-packages/latexrestricted/_restricted_pathlib.py", line 202, in read_text
is_readable, reason = self.readable_file()
^^^^^^^^^^^^^^^^^^^^
File "/nix/store/fyvbk8dn2pwyk2rq0idvw3wvds7b25zg-latexminted-0.1.0b15/lib/python3.12/site-packages/latexminted/restricted/_latexminted_config.py", line 42, in readable_file
is_latex_writable, _ = ResolvedRestrictedPath(self).writable_file()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/vrdb3rg0c3zdzzc06q7glp55qvp5swsz-python3.12-latexrestricted-0.4.0/lib/python3.12/site-packages/latexrestricted/_restricted_pathlib.py", line 661, in writable_file
if self.can_write_dotfiles() or not any(p.name.startswith('.') for p in (self, resolved)):
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/vrdb3rg0c3zdzzc06q7glp55qvp5swsz-python3.12-latexrestricted-0.4.0/lib/python3.12/site-packages/latexrestricted/_restricted_pathlib.py", line 124, in can_write_dotfiles
return latex_config.can_write_dotfiles
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/vrdb3rg0c3zdzzc06q7glp55qvp5swsz-python3.12-latexrestricted-0.4.0/lib/python3.12/site-packages/latexrestricted/_latex_config.py", line 469, in can_write_dotfiles
self._init_write_settings()
File "/nix/store/vrdb3rg0c3zdzzc06q7glp55qvp5swsz-python3.12-latexrestricted-0.4.0/lib/python3.12/site-packages/latexrestricted/_latex_config.py", line 438, in _init_write_settings
cls._init_tex_paths()
File "/nix/store/vrdb3rg0c3zdzzc06q7glp55qvp5swsz-python3.12-latexrestricted-0.4.0/lib/python3.12/site-packages/latexrestricted/_latex_config.py", line 163, in _init_tex_paths
cls._init_tex_paths_texlive()
File "/nix/store/vrdb3rg0c3zdzzc06q7glp55qvp5swsz-python3.12-latexrestricted-0.4.0/lib/python3.12/site-packages/latexrestricted/_latex_config.py", line 205, in _init_tex_paths_texlive
raise LatexConfigError('Environment variable SELFAUTOLOC is expected for TeX Live, but was not set')
latexrestricted.err.LatexConfigError: Environment variable SELFAUTOLOC is expected for TeX Live, but was not set
$ kpsewhich -var-value=SELFAUTOLOC
/nix/store/d4lq8nwx70i8is18rgcw8mvqwjd6aq9z-texlive-combined-2023/bin |
@romildo I just uploaded |
@gpoore It seems that restricted shell escape is not working anymore on my system. Adding the option $ pwd
/home/romildo/tmp/minted
$ python -c "import pathlib; print(pathlib.Path.home().resolve())"
/home/romildo
$ pdflatex test.tex
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/nixos.org) (preloaded format=pdflatex)
restricted \write18 enabled.
[...]
! Package minted Error: minted v3+ executable is not installed, is not added to
PATH, or is not permitted with restricted shell escape.
[...]
$ pdflatex -shell-escape test.tex
[...]
Output written on test.pdf (1 page, 12530 bytes).
Transcript written on test.log.
$ grep 'Package: minted' test.log
Package: minted 2024/08/27 v3.0.0beta13 Yet another Pygments shim for LaTeX |
@romildo Have you modified your |
This is a feature request rather than a bug report.
I am trying to get minted to run in the default restricted shell escape mode of texlive.
I have a latex server (see https://www.learnlatex.org/) returning pdfs generated from user supplied tex source.
It would be nice to be able to include minted examples...
It's running in a fairly sandboxed environment and I'd be prepared to allow pygmentize (which is installed) but not unrestricted shell escape.
So as an experiment I added pygmentize to the list of allowed commands on
texmf.cnf
Unfortunately this doesn't work and minted wants access to
\ShellEscape{rm
and a host of other things that can't be added to the list of allowed shell commands.In such a context I don't need minted to clean up after itself as the entire working directory tree will be deleted the moment the job finishes, so I probably(?) don't need it to have access to
rm
.I started to trace what would need to be changed but got a bit lost, does this sound feasible or are there too many essential shell operations the code relies on?
The text was updated successfully, but these errors were encountered: