I recently changed from Windows to Ubuntu because I'm learning to code. I used to write my class assignments in LaTeX using vscode and Latex Workshop. However, I've tried to set it up in Ubuntu and I've run into multiple errors. I have been able to solve (or at least I think I have) every of them, but I'm unable to solve this last one.
The problem is the following: when trying to build the latex proyect the terminal shows this:
[19:17:56.309][Commander] BUILD command invoked.
[19:17:56.310][Commander] The document of the active editor: file://%WS1%/main
[19:17:56.310][Commander] The languageId of the document: latex
[19:17:56.310][Manager] Current workspace folders: ["file://%WS1%"]
[19:17:56.311][Manager] Found root file from active editor: %WS1%/main
[19:17:56.311][Manager] Keep using the same root file: %WS1%/main
[19:17:56.312][Event] ROOT_FILE_SEARCHED
[19:17:56.312][Commander] Cannot find LaTeX root file. See https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#the-root-file
[19:17:58.322][Cacher] Error loading cache: %WS1%/main . Forcing.
[19:17:58.328][Structure][LaTeX] Error loading content during structuring: %WS1%/main .
[19:17:58.330][Structure] Structure updated with 0 root sections for %WS1%/main .
[19:17:58.333][Event] STRUCTURE_UPDATED
and nothing happens. When I open vscode, it shows this:
[19:17:31.034][Logger] New log placeholder %WS1% registered for /home/alejandro/Documentos/latex/tfm .
[19:17:31.034][Config] latex-workshop.latex.tools: things-that-flagged-the-question-as-spam.
[19:17:31.044][Config] latex-workshop.latex.outDir: "%DIR%/build" .
[19:17:31.085][Manager] Set $LATEXWORKSHOP_DOCKER_LATEX: ""
[19:17:31.093][Server] Creating LaTeX Workshop http and websocket server.
[19:17:31.142][Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":41019} .
[19:17:31.164][Extension] Initializing LaTeX Workshop.
[19:17:31.164][Extension] Extension root: /home/alejandro/.vscode/extensions/james-yu.latex-workshop-9.15.0
[19:17:31.164][Extension] $PATH: /home/alejandro/anaconda3/envs/latex/bin:/home/alejandro/anaconda3/condabin:/usr/local/texlive/2023/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
[19:17:31.165][Extension] $SHELL: /bin/bash
[19:17:31.165][Extension] $LANG: en_US.UTF-8
[19:17:31.165][Extension] $LC_ALL: undefined
[19:17:31.165][Extension] process.platform: linux
[19:17:31.165][Extension] process.arch: x64
[19:17:31.165][Extension] vscode.env.appName: Visual Studio Code
[19:17:31.166][Extension] vscode.env.remoteName: undefined
[19:17:31.166][Extension] vscode.env.uiKind: 1
[19:17:31.166][Extension] LaTeX Workshop initialized.
[19:17:31.173][Format][Bib] Bibtex format config: {"tab":" ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]}
[19:17:31.174][Extension] Trigger characters for intellisense of LaTeX documents: ["\\",",","{"]
[19:17:31.176][Manager] Current workspace folders: ["file://%WS1%"]
[19:17:31.176][Manager] Found root file from active editor: %WS1%/main
[19:17:31.177][Manager] Root file changed: from undefined to %WS1%/main
[19:17:31.177][Manager] Start to find all dependencies.
[19:17:31.177][Manager] Root file languageId: undefined
[19:17:31.177][Event] ROOT_FILE_CHANGED: "%WS1%/main"
[19:17:31.178][Cacher][Watcher] Reset.
[19:17:31.183][Cacher] Adding %WS1%/main .
[19:17:31.185][Cacher][Watcher] Watched %WS1%/main with a new watcher on %WS1% .
[19:17:31.185][Event] FILE_WATCHED: "%WS1%/main"
[19:17:31.186][Event] ROOT_FILE_SEARCHED
[19:17:31.187][Cacher][Path] Non-existent .fls for %WS1%/main .
[19:17:31.298][Server] valdOrigin is http://127.0.0.1:41019
[19:17:35.047][Cacher] Error loading cache: %WS1%/main . Forcing.
[19:17:35.055][Structure][LaTeX] Error loading content during structuring: %WS1%/main .
Now I will enumerate the things I have done to get to this point:
- I first tried to follow TexLive documentation for quick install
- I created a texlive directory in home
- I executed there all the commands in the docs until I got an error on
cd install-tl-*, which for I had to write its full name. - I tried to update the PATH without success.
- Updating PATH: I saw here people having the same problem. I followed the instructions from some of them without success. I tried to do it via the tlmgr gui, again
echo $PATHwas not showing texlive. - I followed Ubuntu's doc for encitomental variables and created a
myenvsvars.shin/etc/profile.d/and putexport PATH=$PATH:/my/which/pdflatex/there. I finally got texlive in PATH, as shown here:
/home/alejandro/anaconda3/envs/latex/bin:/home/alejandro/anaconda3/condabin:/usr/local/texlive/2023/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
- Installed
latexmkviasudo apt install latexmk. - After solving this, I ran into the error I am posting, and tried (just in case) to add the PATH to the env latexworkshop as shown here. Now my
latex-workshop.latex.toolslooks like this:
"command": "latexmk",
"args": [
"--shell-escape",
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {"PATH": "/usr/local/texlive/2023/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin"}
for every env. This didn't really alter the output.
- (added later) I am able to compile latex in terminal.
I think this is pretty much all I have to say. I have used some commands in between from the pages I posted, but I don't really know how those could have messed up the later ones. I'm using Ubuntu 23.10 and I'd highly appreciate some help. Thank you.
export PATH=$PATH:/my/which/pdflatex/? For example, the equivalent snippet from my profile script isexport PATH="/usr/local/texlive/bin:${PATH}". Can you compile a simpletexfile on the command line? If not, what error do you get? What is in/home/alejandro/anaconda3/envs/latex/binand/home/alejandro/anaconda3/condabin? Those are prepended to PATH in vscode. How did you install vscode and latex workshop? – cfr Nov 28 '23 at 20:25export PATH="/usr/local/texlive/2023/bin/x86_64-linux:$PATH", sorry for the confusion.texand turn it into a pdf in terminal, I just did it with the example here./binin my latex enviroment directory. In/condabinthere is only a file calledconda./home/alejandro/Documentos/latex/tfmyour working directory?Ismain.tex` your main TeX file? Because I guess that's what it is looking for. – cfr Nov 28 '23 at 21:28latex-workshop.latex.toolslook odd. Under Windows, environment variables are things like%PATH%, but the same variable under Linux is$PATH. You may need to check what the tool expects. – enkorvaks Nov 28 '23 at 23:44sudo updatedb ; locate pdflatexwhich should show only one file named exactlypdflatex(there are likely others, including a manpagepdflatex.1.gz). If you have more than one, you may have multiple installs. This will lead to some problems, unless you know what you are doing, and are careful. There are some solutions which can be found https://tex.stackexchange.com/a/678711 (Advanced topic, at the end) and https://tex.stackexchange.com/q/676877 and questions linked from that. – enkorvaks Nov 28 '23 at 23:57%for variables they will supply. At least, it is common on Linux and Mac. If Windows uses that for environmental variables, perhaps they use something else on that platform. For example, Kile uses%in this way so scripts can make use of information provided by the editor e.g. the filename or the selected text or whatever. – cfr Nov 29 '23 at 00:17which -a pdflatexmay give more manageable output thanlocate. On my machine,locate pdflatexreturns 192 results, including 5 exact matches.which -a pdflatexreturns 2 (and those are identical). – cfr Nov 29 '23 at 00:21%NAME%and don't recall that anywhere else. I also made this suggestion because Alex Moreno has moved from Windows to Linux, and I suspected that the files might have been using Windows variables, and were copied to Linux without change (and now don't work). I am content to be wrong about that, though (if I am wrong, then I have learnt something today). – enkorvaks Nov 29 '23 at 03:17%for variables. (Of course, not for environmental variables.) And I think TeXShop did the same on Mac, but it's a long time since I've used a Mac. So I'm familiar with this and I've never used a TeX editor on Windows. PlusNew log placeholder %WS1% registered for /home/alejandro/Documentos/latex/tfm .looks as if it might be an assignment by the editor rather than a configuration setting. Moreover, I'd expect syntax errors if%wasn't intercepted by the editor. – cfr Nov 29 '23 at 04:16/home/alejandro/Documentos/latex/tfmwas indeed the working directory.which -a pdflatexshows 4 locations:/usr/local/texlive/2023/bin/x86_64-linux/pdflatex,/usr/local/bin/pdflatex,/usr/bin/pdflatex,/bin/pdflatex. – Alex Moreno Dec 03 '23 at 22:45/usr/local/texliveand make sure all relevant Ubuntu packages are installed or uninstall Ubuntu's and replace with a 'dummy' package to satisfy your package manager. – cfr Dec 03 '23 at 23:03which -a pdflatexshows/usr/bin/pdflatexand/bin/pdflatex. – Alex Moreno Dec 04 '23 at 19:41