LaTeX-Workshop: Cannot compile .tex files on MacOS

Description

Compiling of the .tex files will not work, so I am not able to use the workflow in my VSCode on MacOS. I suspect this might be related to the location of my files, which are on iCloud Drive, so the path might be a bit ‘ugly’.

This is the error message I get:

Latexmk: applying rule 'pdflatex'...
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
! I can't find file `"/Users/ahmet/Library/Mobile Documents/com"'.
<to be read again> 
                   \protect 
<*> "/Users/ahmet/Library/Mobile Documents/com~
                                               apple~CloudDocs/Southampton/P...
(Press Enter to retry, or Control-D to exit)
Please type another input file name
! Emergency stop.
<to be read again> 
                   \protect 
<*> "/Users/ahmet/Library/Mobile Documents/com~
                                               apple~CloudDocs/Southampton/P...
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on texput.log.
=== TeX engine is 'pdfTeX'
Latexmk: Errors, so I did not complete making targets

I have tried quite a few things:

  • removing all whitespace from the complete path to the file
  • creating a symbolic link, so ~/Paper/ is the directory where all .tex files are located
  • tried hardcoding the path in the workflow in settings
  • tried creating an alias command and just putting that in the workflow settings without any arguments

Whatever I do, the error appears. I am able to run the command for latexmk manually from the terminal, so if I run latexmk -synctex=1 -interaction=nonstopmode -file-line-error -pdf -f ~/Paper/Thesis.tex the file gets built.

Expected behavior

I expect a PDF to be generated, that the compiling process is completed.

Actual behavior

There is an error message, with the log that I have showed above.

Log messages

LaTeX Workshop Output file: 'file:///Users/ahmet/Library/Mobile%20Documents/com~apple~CloudDocs/Southampton/ProjectPrep/MScProject/Code/novelchain/Paper/Thesis.tex' severity: 'Error' message: 'I can't find file `"/Users/ahmet/Library/Mobile Documents/com"' <to be read again> \protect <*> "/Users/ahmet/Library/Mobile Documents/com~ apple~CloudDocs/Southampton/P... (Press Enter to retry, or Control-D to exit) Please type another input file name ! Emergency stop. <to be read again> \protect <*> "/Users/ahmet/Library/Mobile Documents/com~ apple~CloudDocs/Southampton/P... ! ==> Fatal error occurred, no output PDF file produced! Transcript written on texput.log. === TeX engine is 'pdfTeX' Latexmk: Errors, so I did not complete making targets ' at: '1,1' source: 'LaTeX'
Developer Tools Console

Additional Information

I am using MacOS X, latest version, 10.12.6.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 29 (14 by maintainers)

Most upvoted comments

Here’s mine:

"latex-workshop.latex.recipes": [
	{
		"name": "latexmk",
		"tools": ["cd_to_cwd", "latexmk"]
	},
	{
		"name": "pdflatex -> bibtex -> pdflatex*2",
		"tools": ["cd_to_cwd", "pdflatex", "bibtex", "pdflatex", "pdflatex"]
	}
],
"latex-workshop.latex.tools": [
	{
		"name": "cd_to_cwd",
		"command": "cd",
		"args": ["%DIR%"]
	},
	{
		"name": "latexmk",
		"command": "latexmk",
		"args": [
			"-synctex=1",
			"-interaction=nonstopmode",
			"-file-line-error",
			"-pdf",
			"%DOCFILE%"
		]
	},
	{
		"name": "pdflatex",
		"command": "pdflatex",
		"args": [
			"-synctex=1",
			"-interaction=nonstopmode",
			"-file-line-error",
			"%DOCFILE%"
		]
	},
	{
		"name": "bibtex",
		"command": "bibtex",
		"args": ["%DOCFILE%"]
	}
],

The key is that a) the first recipe listed is used by default; b) the recipe used has to contain the cd tool.

Another Workaround

  1. Create a symbolic link to the iCloud folder, for example:

    $ ln -s "~/Library/Mobile Documents/com~apple~CloudDocs/" iCloud
    
  2. Open Visual Studio Code on that folder without following the symbolic link (a feature new to 1.28), for example:

    $ code iCloud/Research/papers
    

For me this works:

“latex-workshop.latex.toolchain”: [ {“command”: “cd”, “args” : [“%DIR%”] }, {“command”: “pdflatex”, “args”: [ “-synctex=1”, “-interaction=nonstopmode”, “-file-line-error”, “%DOCFILE%” ] } Then the pdflatex command does not have tildes in its argument anymore.

ps sorry for duplicating before.

Would it be possible for LaTeX-Workshop to automatically cd into the compilation directory before compiling, rather than specify the full path to the file? This would eliminate this problem (which I understand is caused by the latex command). @Mollenboot’s fix works, but is a bit annoying, especially since it had to be reworked for the new toolchain format, and may need to be reworked again in the future.

@ashthespy Let me check how it works for this extension. I never noticed problems, but this can because my tex project is usually small enough.