I had the same problem. The root cause was: (1) software’s bin folder missing from PATH; (2) bad file privileges. Consequently, VSC couldn’t access latexmk, which explains the error messages.
In my case, the problem occurred on a mac, and specifically after I installed MacTex, which, in turn, installs Tex Live. I believe the same solution may apply to linux distros too.
Solution:
-
Claim file ownership (which was originally root) under folder
/usr/local/texlive:sudo chown -R <username> /usr/local/texlive, where<username>is the OS-level user name. The fix will work for this specific user. If it is not enough, try instead setting group owner appropriately, and/or consider Step 3. -
Add
/usr/local/texlive/2021/bin/<software_dialect>to PATH.<software_dialect>depends on the installed software version: in my case it isuniversal-darwin; on linux it might bex86_64-linux. -
If the problem persists, try to change file access permissions under
/usr/local/texliveusingchmod.
EDIT: As a final step, restart VSC for changes to take effect.