Latex-workshop: Invoking shell-escape flag (again)

Created on 4 Dec 2018  路  7Comments  路  Source: James-Yu/LaTeX-Workshop

This is to reopen my issue #913.
To invoke shell-escape flag I tried this in my user settings:

 "latex-workshop.latex.recipes": [
        {
            "name": "latexmk",
            "tools": [
                "pdflatex",
                "bibtex",
                "pdflatex",
                "pdflatex"
            ]       
        },
    ],
    "latex-workshp.latex.tools":[{
        "name": "latexmk",
        "command": "pdflatex",
        "--shell-escape",
        "%O",
        "%S"
    }],

But I got errors. Is this right?

Most helpful comment

I found the solution in StackExchange:

// in USER SETTINGS add the following
"latex-workshop.latex.tools": [
    {
        "name": "latexmk",
        "command": "latexmk",
        "args": [
            "--shell-escape", // added arg to default
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "-pdf",
            "%DOC%"
        ]
    },
    {
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
            "--shell-escape", // added arg to default
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
        ]
    },
    {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
            "%DOCFILE%"
        ]
    }
]

All 7 comments

I tried this but I got problems with the bibliography. What have I done wrong?

 "latex-workshop.latex.recipes": [
        {
            "name": "latexmk",
            "tools": [
                "latexmk",
                "bibtex",
                "latexmk",
                "latexmk"
            ]

        },
    "latex-workshp.latex.tools": [
        {
            "name": "latexmk",
            "command": "pdflatex",
            "args ": [
                "-pdf",
                "-pdflatex=\"pdflatex --shell-escape %O %S\""
            }
        ]

Sorry, there was a typo in my previous post. latexmk already takes care of the bibliography.

"latex-workshop.latex.recipes": [
        {
            "name": "latexmk",
            "tools": [
                "latexmk"
            ]

        },
    "latex-workshp.latex.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args ": [
                "-pdf",
                "-pdflatex=pdflatex -shell-escape %O %S"
            }
        ]

There were some typos also in latex-workshop.latex.tools. Now corrected:
```
"latex-workshop.latex.tools": [
{
"name": "latexmk",
"command": "latexmk",
"args ": [
"-pdf",
"-pdflatex=\"pdflatex --shell-escape %O %S\""
]
}
]

But problems remain. Here is part of the output:

Latexmk: This is Latexmk, John Collins, 7 August 2018, version: 4.59.
Rule 'latex': Rules & subrules not known to be previously run:
latex
Rule 'latex': The following rules & subrules became out-of-date:

'latex'

Run number 1 of rule 'latex'


Running 'latex -recorder "paper_OL_LNCS.tex"'

(and so on...). And ends with:

Package ifplatform Warning:
shell escape is disabled, so I can only detect \ifwindows.

) (/usr/local/texlive/2018/texmf-dist/tex/generic/xstring/xstring.sty (/usr/local/texlive/2018/texmf-dist/tex/generic/xstring/xstring.tex)) (/usr/local/texlive/2018/texmf-dist/tex/latex/framed/framed.sty))

! Package minted Error: You must invoke LaTeX with the -shell-escape flag.

See the minted package documentation for explanation.
Type H for immediate help.
...

l.31 \usepackage
{csquotes}
?
```
I must say that the same file compiles well with Emacs (AucTeX).

Does it work if you directly run latexmk -pdf -pdflatex="pdflatex --shell-escape %O %S" from the command line?

From the log, latexmk is not running withe the right arguments. Are you sure you do not have a second tool with the same name?

Yes, now it compiles well from the command line. I don't understand what happens when I don't use the command line. I don't see any second tool with the same name (latexmk).
These are the first lines of the output (they are different from those above):

Latexmk: This is Latexmk, John Collins, 7 August 2018, version: 4.59.
Latexmk: applying rule 'bibtex paper_OL_LNCS'...
Rule 'bibtex paper_OL_LNCS': File changes, etc:
   Non-existent destination files:
      'paper_OL_LNCS.bbl'
------------
Run number 1 of rule 'bibtex paper_OL_LNCS'
------------
For rule 'bibtex paper_OL_LNCS', running '&run_bibtex(  )' ...
------------
Running 'bibtex  "paper_OL_LNCS"'
------------
This is BibTeX, Version 0.99d (TeX Live 2018)
The top-level auxiliary file: paper_OL_LNCS.aux
The style file: apalike.bst
Database file #1: sbphd.bib
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex': File changes, etc:
   Changed files, or newly in use since previous run(s):
      '/Users/sergiobacelar/Dropbox/PhD/Papers/Generational-political-dynamics-LNCS-/paper_OL_LNCS.tex'
      'paper_OL_LNCS.aux'
      'paper_OL_LNCS.bbl'
      'paper_OL_LNCS.tex'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex --shell-escape  -recorder  "paper_OL_LNCS.tex"'

Clearly, latex-workshop does not launch the correct tool, so there must be something wrong in there.

I found the solution in StackExchange:

// in USER SETTINGS add the following
"latex-workshop.latex.tools": [
    {
        "name": "latexmk",
        "command": "latexmk",
        "args": [
            "--shell-escape", // added arg to default
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "-pdf",
            "%DOC%"
        ]
    },
    {
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
            "--shell-escape", // added arg to default
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
        ]
    },
    {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
            "%DOCFILE%"
        ]
    }
]
Was this page helpful?
0 / 5 - 0 ratings

Related issues

LordScree picture LordScree  路  5Comments

dslemusp picture dslemusp  路  4Comments

jabooth picture jabooth  路  3Comments

tillahoffmann picture tillahoffmann  路  6Comments

domenicozambella picture domenicozambella  路  4Comments