'LaTeX Extension doesn't work on VS Code and keeps giving ENOENT error

This is what my Terminal shows for $PATH

/Library/Frameworks/Python.framework/Versions/3.8/bin:/Users/sathvik/opt/anaconda3/bin:/Users/sathvik/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Library/Apple/usr/bin:/usr/local/mysql/bin: No such file or directory

I have deleted all possible files linked to LaTeX which I got from MacTeX and I have installed MiKTeX. The following is the path for MiKTeX

/Applications/MiKTeX Console.app/Contents/bin

I want to use LaTeX in VS Code and I only have the Latex Workshop Extensionand Code Runner Enabled (reload is done).The following is my JSON Settings.

{
"python.defaultInterpreterPath": "/usr/bin/python3",
"code-runner.runInTerminal": true,
"notebook.lineNumbers": "on",

"code-runner.executorMap": {
"javascript": "node",
"java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"php": "php",
"python": "python",
"perl": "perl",
"perl6": "perl6",
"ruby": "ruby",
"go": "go run",
"lua": "lua",
"groovy": "groovy",
"powershell": "powershell -ExecutionPolicy ByPass -File",
"bat": "cmd /c",
"shellscript": "bash",
"fsharp": "fsi",
"csharp": "scriptcs",
"vbscript": "cscript //Nologo",
"typescript": "ts-node",
"coffeescript": "coffee",
"scala": "scala",
"swift": "swift",
"julia": "julia",
"crystal": "crystal",
"ocaml": "ocaml",
"r": "Rscript",
"applescript": "osascript",
"clojure": "lein exec",
"haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
"rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
"racket": "racket",
"scheme": "csi -script",
"ahk": "autohotkey",
"autoit": "autoit3",
"dart": "dart",
"pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
"d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
"haskell": "runhaskell",
"nim": "nim compile --verbosity:0 --hints:off --run",
"lisp": "sbcl --script",
"kit": "kitc --run",
"v": "v run",
"sass": "sass --style expanded",
"scss": "scss --style expanded",
"less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
"FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"latex": "latex"

},
"latex-workshop.latex.recipes": [
    {
      "name": "latexmk 🔃",
      "tools": [
        "latexmk"
      ]
    },
    {
      "name": "pdflatex ➞ bibtex ➞ pdflatex`×2",
      "tools": [
        "pdflatex",
        "bibtex",
        "pdflatex",
        "pdflatex"
      ]
    }
  ],

  "latex-workshop.latex.tools": [
    {
      "name": "latexmk",
      "command": "latexmk",
      "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "-pdf",
        "-outdir=%OUTDIR%",
        "%DOC%"
      ],
      "env": {}
    },
    {
      "name": "pdflatex",
      "command": "pdflatex",
      "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "%DOC%"
      ],
      "env": {}
    },
    {
      "name": "bibtex",
      "command": "bibtex",
      "args": [
        "%DOCFILE%"
      ],
      "env": {}
    }
  ],

"terminal.integrated.inheritEnv": false,
"jupyter.jupyterServerType": "local",
"workbench.iconTheme": "vscode-icons",
"window.zoomLevel": 2,
"notebook.consolidatedRunButton": true,
"code-runner.saveFileBeforeRun": true,


"terminal.integrated.commandsToSkipShell": [
    "language-julia.interrupt"
],
"julia.symbolCacheDownload": true,
"julia.executablePath": "/Applications/Julia-1.7.app/Contents/Resources/julia/bin/julia ",


"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": "active",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"snyk.features.openSourceSecurity": false,
"snyk.features.codeSecurity": false,
"julia.enableTelemetry": true,
"python.diagnostics.sourceMapsEnabled": true,
"python.disableInstallationCheck": true,
"bracketPairColorizer.depreciation-notice": false,
"extension.runMatlab": "/Applications/MATLAB_R2021b.app/Contents/MacOS/MATLAB",
"arduino.path": "/Users/sathvik/Desktop/Arduino.app",
"files.exclude": {
    "**/.classpath": true,
    "**/.project": true,
    "**/.settings": true,
    "**/.factorypath": true
}
}

I've exhausted every possible resource but no matter what I do, every time I try to build my LaTeX project, I keep getting the following error:

[20:16:24] The document of the active editor: file:///Users/sathvik/Desktop/TeX            Files/Hertz's Experiment_1.tex
    [20:16:24] The languageId of the document: latex
    [20:16:24] Current workspace folders: ["file:///Users/sathvik/Desktop"]
    [20:16:24] Current workspaceRootDir: file:///Users/sathvik/Desktop
    [20:16:24] Found root file from active editor: /Users/sathvik/Desktop/TeX Files/Hertz's Experiment_1.tex
    [20:16:24] Keep using the same root file: /Users/sathvik/Desktop/TeX Files/Hertz's Experiment_1.tex
    [20:16:24] Building root file: /Users/sathvik/Desktop/TeX Files/Hertz's Experiment_1.tex
    [20:16:24] Build root file /Users/sathvik/Desktop/TeX Files/Hertz's Experiment_1.tex
    [20:16:24] outDir: /Users/sathvik/Desktop/TeX Files
    [20:16:24] Recipe step 1: latexmk, -synctex=1,-interaction=nonstopmode,-file-line-error,-pdf,-outdir=/Users/sathvik/Desktop/TeX Files,/Users/sathvik/Desktop/TeX  Files/Hertz's Experiment_1
    [20:16:24] Recipe step env: {}
    [20:16:24] cwd: /Users/sathvik/Desktop/TeX Files
    [20:16:24] LaTeX build process spawned. PID: undefined.
    [20:16:24] LaTeX fatal error: spawn latexmk ENOENT, . PID: undefined.
    [20:16:24] Does the executable exist? $PATH:   /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Library/Apple/usr/bin
    [20:16:24] Does the executable exist? $Path: undefined
    [20:16:24] The environment variable $SHELL: /bin/zsh
    [20:16:26] Manager.fileWatcher.getWatched: {"/Users/sathvik/Desktop/TeX Files":      ["Hertz's Experiment_1.tex"]}
    [20:16:26] Manager.filesWatched: ["/Users/sathvik/Desktop/TeX Files/Hertz's Experiment_1.tex"]
[20:16:26] BibWatcher.bibWatcher.getWatched: {}
[20:16:26] BibWatcher.bibsWatched: []
[20:16:26] PdfWatcher.pdfWatcher.getWatched: {}  
[20:16:26] PdfWatcher.pdfsWatched: []'

And

Recipe terminated with fatal error: spawn latexmk ENOENT.

If any more information is required, please request so. I'm honestly exhausted from this and would really appreciate it if anyone would help me with this problem.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source