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

latexmk portion of recipe terminates with error "perl not found" #2390

Closed
kir12 opened this issue Nov 23, 2020 · 19 comments
Closed

latexmk portion of recipe terminates with error "perl not found" #2390

kir12 opened this issue Nov 23, 2020 · 19 comments
Labels
question Issue represents a question

Comments

@kir12
Copy link

kir12 commented Nov 23, 2020

Preliminary questions [Required]

Disable all the other extensions except for LaTeX Workshop, and check that you still see this issue. [Required]

You still see this issue?: Yes/No

Make sure to visit the wiki FAQ before filling an issue.

You visited the wiki?: Yes/No

If your issue is with compiling a document (not having to do with finding the root file of a project), check first that you can compile manually.

You can compile a TeX document manually?: Yes/No

Describe the bug [Required]

When I run the stock LaTeX build recipe, latexmk reports that perl cannot be found on my system. I've double checked that (a) perl -v works properly and is installed on my system and (b) pdflatex and latexmk work when directly called on my terminal. (i.e. TeX Live is properly installed on my system) My immediate thought was that my PATH was set wrong somewhere, but that seems very unlikely since all of the previous commands worked as expected. I'm out of ideas what could be going wrong -- does anyone know what's going wrong?

I'm using TeX Live (installed directly from TeXGroup's website) on Arch Linux.

To Reproduce

Steps to reproduce the behavior:

  1. Install a fresh copy of LaTeX-Workshop from the VSCode Marketplace
  2. Select an arbitrary valid .tex file
  3. Go to the "TeX" tab on the left sidebar, then click "Build LaTeX Project." Inside the Output tab on the bottom of the screen, the error
/usr/bin/env: ‘perl’: No such file or directory

appears.

Expected behavior

Either (a) the project should cleanly compile (since it does successfully compile when directly run) or (b) an error that isn't perl-related pops up and happens after the initial latexmk recipe.

Logs [Required]

Please paste the whole log messages here, not parts of ones. The log should start with Initializing LaTeX Workshop. It is very important to identify problems.

LaTeX Workshop Output [Required]

[13:57:44] Initializing LaTeX Workshop.
[13:57:44] Extension root: /home/brianl/.vscode-oss/extensions/james-yu.latex-workshop-8.14.0
[13:57:44] Creating PDF file watcher.
[13:57:44] Creating LaTeX Workshop http and websocket server.
[13:57:45] LaTeX Workshop initialized.
[13:57:45] Current workspace folders: ["file:///home/brianl/Projects/umich-junior/eecs388/sguide"]
[13:57:45] Current workspaceRootDir: /home/brianl/Projects/umich-junior/eecs388/sguide
[13:57:45] Found root file from active editor: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:57:45] Root file changed: from undefined to /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:57:45] Start to find all dependencies.
[13:57:45] Root file languageId: latex
[13:57:45] Instantiating a new file watcher for /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:57:45] Creating Bib file watcher.
[13:57:45] Parsing a file and its subfiles: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:57:45] Parsing a file and its subfiles: /home/brianl/Projects/umich-junior/eecs388/sguide/ch1/ch1.tex
[13:57:45] Parse fls file.
[13:57:45] Cannot find fls file: /home/brianl/Projects/umich-junior/eecs388/sguide/ch1/ch1.fls
[13:57:45] Parse fls file.
[13:57:45] Cannot find fls file: /home/brianl/Projects/umich-junior/eecs388/sguide/main.fls
[13:57:45] Server created on 127.0.0.1:35633
[13:57:45] Added to file watcher: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:57:45] Added to file watcher: /home/brianl/Projects/umich-junior/eecs388/sguide/ch1/ch1.tex
[13:57:45] Snippet data loaded.
[13:57:45] LaTeX Workshop version: 8.14.0
[13:59:29] Current workspace folders: ["file:///home/brianl/Projects/umich-junior/eecs388/sguide"]
[13:59:29] Current workspaceRootDir: /home/brianl/Projects/umich-junior/eecs388/sguide
[13:59:29] Found root file from active editor: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:59:29] Keep using the same root file: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:59:31] BUILD command invoked.
[13:59:31] The document of the active editor: output:extension-output-%233
[13:59:31] The languageId of the document: Log
[13:59:31] Cannot find LaTeX root file.
[13:59:37] BUILD command invoked.
[13:59:37] The document of the active editor: output:extension-output-%233
[13:59:37] The languageId of the document: Log
[13:59:37] Cannot find LaTeX root file.
[13:59:38] BUILD command invoked.
[13:59:38] The document of the active editor: output:extension-output-%233
[13:59:38] The languageId of the document: Log
[13:59:38] Cannot find LaTeX root file.
[13:59:41] Current workspace folders: ["file:///home/brianl/Projects/umich-junior/eecs388/sguide"]
[13:59:41] Current workspaceRootDir: /home/brianl/Projects/umich-junior/eecs388/sguide
[13:59:41] Found root file from active editor: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:59:41] Keep using the same root file: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:59:43] BUILD command invoked.
[13:59:43] The document of the active editor: output:extension-output-%233
[13:59:43] The languageId of the document: Log
[13:59:43] Cannot find LaTeX root file.
[13:59:45] BUILD command invoked.
[13:59:45] The document of the active editor: output:extension-output-%233
[13:59:45] The languageId of the document: Log
[13:59:45] Cannot find LaTeX root file.
[13:59:46] Current workspace folders: ["file:///home/brianl/Projects/umich-junior/eecs388/sguide"]
[13:59:46] Current workspaceRootDir: /home/brianl/Projects/umich-junior/eecs388/sguide
[13:59:46] Found root file from active editor: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:59:46] Keep using the same root file: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:59:47] BUILD command invoked.
[13:59:47] The document of the active editor: file:///home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:59:47] The languageId of the document: latex
[13:59:47] Current workspace folders: ["file:///home/brianl/Projects/umich-junior/eecs388/sguide"]
[13:59:47] Current workspaceRootDir: /home/brianl/Projects/umich-junior/eecs388/sguide
[13:59:47] Found root file from active editor: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:59:47] Keep using the same root file: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:59:47] Building root file: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:59:47] Build root file /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:59:48] Recipe step 1: latexmk, -synctex=1,-interaction=nonstopmode,-file-line-error,-pdf,-outdir=/home/brianl/Projects/umich-junior/eecs388/sguide,/home/brianl/Projects/umich-junior/eecs388/sguide/main
[13:59:48] cwd: /home/brianl/Projects/umich-junior/eecs388/sguide
[13:59:48] LaTeX build process spawned. PID: 2798.
[13:59:48] Recipe returns with error: 127/null. PID: 2798. message: /usr/bin/env: ‘perl’: No such file or directory
.
[13:59:48] The environment variable $PATH: /opt/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
[13:59:48] The environment variable $SHELL: /bin/bash
[13:59:48] Cleaning auxiliary files and retrying build after toolchain error.
[13:59:48] Recipe step 1: latexmk, -synctex=1,-interaction=nonstopmode,-file-line-error,-pdf,-outdir=/home/brianl/Projects/umich-junior/eecs388/sguide,/home/brianl/Projects/umich-junior/eecs388/sguide/main
[13:59:48] cwd: /home/brianl/Projects/umich-junior/eecs388/sguide
[13:59:48] LaTeX build process spawned. PID: 2799.
**[13:59:48] Recipe returns with error: 127/null. PID: 2799. message: /usr/bin/env: ‘perl’: No such file or directory**
.
[13:59:48] The environment variable $PATH: /opt/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
[13:59:48] The environment variable $SHELL: /bin/bash
[13:59:53] Current workspace folders: ["file:///home/brianl/Projects/umich-junior/eecs388/sguide"]
[13:59:53] Current workspaceRootDir: /home/brianl/Projects/umich-junior/eecs388/sguide
[13:59:53] Found root file from active editor: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[13:59:53] Keep using the same root file: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[14:03:03] Current workspace folders: ["file:///home/brianl/Projects/umich-junior/eecs388/sguide"]
[14:03:03] Current workspaceRootDir: /home/brianl/Projects/umich-junior/eecs388/sguide
[14:03:03] Found root file from active editor: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[14:03:03] Keep using the same root file: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[14:04:25] Current workspace folders: ["file:///home/brianl/Projects/umich-junior/eecs388/sguide"]
[14:04:25] Current workspaceRootDir: /home/brianl/Projects/umich-junior/eecs388/sguide
[14:04:25] Found root file from active editor: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex
[14:04:25] Keep using the same root file: /home/brianl/Projects/umich-junior/eecs388/sguide/main.tex

Developer Tools Console [Required]

Nothing particularly suspicious came up when Developer Tools was toggled.

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop [Required]

  • OS: Arch Linux
  • VS Code version: 1.51.1 (Note: it's the open-source fork of the editor, OSS)
  • Extension version: 8.14.0
  • TeX distribution version: TeX Live 2020

Additional questions

Are you using VSCodium?

Yes/No

Are you using LaTeX Workshop with VS Code Remote?

Yes/No

If the answer is Yes, please write which one you are using. Write the versions of the remote extension.

  • Remote Containers/Remote SSH/Remote WSL
  • Remote Extension Version: [e.g. 0.48.0]

Additional context

Add any other context about the problem here.

@jlelong
Copy link
Collaborator

jlelong commented Nov 23, 2020

This is mostly because your PATH is wrong inside vscode, see https://github.com/James-Yu/LaTeX-Workshop/wiki/Install#setting-path-environment-variable and the references therein.

@jlelong jlelong closed this as completed Nov 23, 2020
@kir12
Copy link
Author

kir12 commented Nov 23, 2020

your PATH is wrong inside vscode

I'm not sure what you mean by this. Could you clarify by chance?

@jlelong
Copy link
Collaborator

jlelong commented Nov 23, 2020

Check the following two commands in your terminal (not inside vscode's terminal)

/usr/bin/env perl
echo $PATH

Compare the output of the second command with /opt/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

@kir12
Copy link
Author

kir12 commented Nov 23, 2020

The first command doesn't do anything significant since it's only waiting for Perl input. As for the second command, the PATH you gave directly matches with the output I get, except /usr/local/texlive/2020/bin/x86_64-linux: is appended to the front.

@jlelong
Copy link
Collaborator

jlelong commented Nov 23, 2020

What is the output of which perl?

@kir12
Copy link
Author

kir12 commented Nov 23, 2020

/usr/bin/perl -- ah is is it because that specific directory wasn't added to my PATH?

@jlelong
Copy link
Collaborator

jlelong commented Nov 23, 2020

Yet, /usr/bin is in the PATH reported by vscode /opt/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl.

You have to investigate why usr/bin/env perl does not work inside vscode. Is there something related to perl inside /usr/local/texlive/2020/bin/x86_64-linux?

@kir12
Copy link
Author

kir12 commented Nov 23, 2020

I wasn't able to find anything related to perl inside /usr/local/texlive/2020/bin/x86_64-linux. However, I will note that /usr/bin/env perl does work inside my vscode. (I was able to verify by typing in gibberish and receiving back syntax errors)

@jlelong

This comment has been minimized.

@kir12

This comment has been minimized.

@jlelong
Copy link
Collaborator

jlelong commented Nov 23, 2020

However, I will note that /usr/bin/env perl does work inside my vscode

This is because the PATH inside vscode's terminal is not the one inside the GUI app before launching an internal shell session. The difference lies in /usr/local/texlive/2020/bin/x86_64-linux. Check if it works with the same PATH in vscode. See here for where to set your PATH.

@kir12
Copy link
Author

kir12 commented Nov 23, 2020

Do you mean something like /usr/local/texlive/2020/bin/x86_64-linux/latexmk? That specific command worked inside VSCode.

@tamuratak
Copy link
Contributor

tamuratak commented Nov 23, 2020

Please show us:

  • Your settings file of VS Code, settings.json
  • The fist line, shebang, of the latexmk

[13:57:44] Extension root: /home/brianl/.vscode-oss/extensions/james-yu.latex-workshop-8.14.0

Notice that you are using an unofficial build of VS Code, which we do not officially support. See microsoft/vscode#107997 (comment)

@tamuratak tamuratak added can't reproduce Issue cannot be reproduced need more info More information needed to identify the issue labels Nov 23, 2020
@kir12
Copy link
Author

kir12 commented Nov 24, 2020

Here's the portion of settings.json relevant to LaTeX-Workshop:

{
    "latex-workshop.view.pdf.viewer": "tab",
    "latex-workshop.latex.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {"PATH":"/usr/local/texlive/2020/bin/x86_64-linux/"}
        },
        {
            "name": "lualatexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-lualatex",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {}
        },
        {
            "name": "latexmk_rconly",
            "command": "latexmk",
            "args": [
                "%DOC%"
            ],
            "env": {}
        },
        {
            "name": "pdflatex",
            "command": "pdflatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ],
            "env": {"PATH":"/usr/local/texlive/2020/bin/x86_64-linux/"}
        },
        {
            "name": "bibtex",
            "command": "bibtex",
            "args": [
                "%DOCFILE%"
            ],
            "env": {}
        },
        {
            "name": "rnw2tex",
            "command": "Rscript",
            "args": [
                "-e",
                "knitr::opts_knit$set(concordance = TRUE); knitr::knit('%DOCFILE_EXT%')"
            ],
            "env": {}
        },
        {
            "name": "jnw2tex",
            "command": "julia",
            "args": [
                "-e",
                "using Weave; weave(\"%DOC_EXT%\", doctype=\"tex\")"
            ],
            "env": {}
        },
        {
            "name": "jnw2texmintex",
            "command": "julia",
            "args": [
                "-e",
                "using Weave; weave(\"%DOC_EXT%\", doctype=\"texminted\")"
            ],
            "env": {}
        }
    ],
    "go.formatTool": "goimports",
    "[go]": {

        "editor.insertSpaces": false,
        "editor.formatOnSave": false,
        "editor.codeActionsOnSave": {
            "source.organizeImports": false
        }
    },
    "python.diagnostics.sourceMapsEnabled": true,
    "[latex]": {
    
    
        "editor.formatOnPaste": false,
        "editor.suggestSelection": "recentlyUsedByPrefix"
    }
}

Can you clarify where to find latexmk's shebang?

Lastly, does you mean LaTeX-Workshop doesn't support OSS? (My understanding was that OSS is essentially VSCode minus Microsoft branding, but if there is a bigger difference please let me know)

@tamuratak
Copy link
Contributor

tamuratak commented Nov 24, 2020

"env": {"PATH":"/usr/local/texlive/2020/bin/x86_64-linux/"}

This is the cause. It overrides the PATH environment variable. It does not append the value to PATH. See:

@tamuratak tamuratak added question Issue represents a question and removed can't reproduce Issue cannot be reproduced need more info More information needed to identify the issue labels Nov 24, 2020
@seragunn
Copy link
Contributor

Can you clarify where to find latexmk's shebang?

head -n1 $(which latexmk)

Lastly, does you mean LaTeX-Workshop doesn't support OSS? (My understanding was that OSS is essentially VSCode minus Microsoft branding, but if there is a bigger difference please let me know)

I use the Code-OSS build Arch Linux provides on both my machines without issue. The issue is that Arch Linux uses it's own native electron package rather than the one provided in the code repository which caused one issue. Then there was an issue with how open-vsx was packaging the extension (#2160). Both issues are resolved now and hopefully there are no further issues but we do not control the Arch Linux package/VSCodium/the open-vsx package so we would like to test the official extension on the official build to know if the issue is on our end or somewhere else.

@kir12
Copy link
Author

kir12 commented Nov 24, 2020

"env": {"PATH":"/usr/local/texlive/2020/bin/x86_64-linux/"}

This is the cause. It overrides the PATH environment variable. It does not append the value to PATH. See:

Hmm yeah, that seems to have been a symptom of the root problem, as when I took out the env attribute, I got a new error:

LaTeX fatal error: spawn latexmk ENOENT, . PID: undefined

Now I can see the problem clearly: PATH according to LaTeX-Workshop doesn't have my TeX Live directory included

Does the executable exist? PATH: /opt/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

However PATH according to VSCode's internal terminal (and my standalone terminal) indicate otherwise:

[brianl@brian-pc:~]$ echo $PATH
/usr/local/texlive/2020/bin/x86_64-linux:/opt/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

According to the documentation entry on environment variables this means something's broken with my LaTeX setup. As I mentioned earlier, pdflatex and latexmk both work fine (and doing where <CMD> points to my Tex Live directory) so I have no idea what exactly is wrong with my Tex Live setup. The documentation also recommends manually setting the directory with the env parameter ... which I had to take out to resolve the original error. Any ideas on how I should proceed?

@tamuratak
Copy link
Contributor

Please add the following to your setting instead of the previous one:

"env": {"PATH":"/usr/local/texlive/2020/bin/x86_64-linux:/opt/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl"}

@kir12
Copy link
Author

kir12 commented Nov 24, 2020

Well I'll be damned, that worked! Sorry for bugging you with so many small questions.

Repository owner locked as resolved and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Issue represents a question
Projects
None yet
Development

No branches or pull requests

4 participants