For several years I've been able to export to PDF using pdflatex regardless of whether or not there was spaces in the directory path or filename.

On Windows 10 Home (Version 1607) I installed LyX 2.2.0 (2016 October 10), and when I try exporting with pdflatex I get the error "Directory path to the document cannot contain spaces".

This seems to be a very common error that is never properly addressed:

  1. Latex Community: Blank Space(s) in Directory Path - Suggested solution was to de-select 'updates on the fly' in MikTeX but as others said in their replies, it doesn't work for everyone.
  2. LyX Users: Directory path to the document cannot contain spaces - Suggested solution here was just to remove the spaces in the directory path, which is not actually a solution.
  3. Linux Questions: lyx help... directory path to the document cannot contain spaces - Suggested solution was to put the whole file path in quotes, but this seems to only be possible using command line LyX in Linux, it is not a solution for Windows.

What is a solution that works for LyX 2.2.0 in Windows 10 ?

  • 3
    IMHO running W10 is not an option at all but if your life depends on it you could run LaTeX from a VM having an linux installed. Oracles VirtualBox is free and can directly access a certain folder on the host to writ the pdf to. Commented Dec 18, 2016 at 21:29
  • I had used LyX on W10 where all my user paths cointained a blank (because my user was name surname) without problems for months, I added "..." when needed (now I've given up LyX and also reinstalled W10 with user name but for other reasons). Maybe you have to put the quotes in the paths saved in your LyX options. I also suggest to you to reinstall LyX using the new bins from the LyX site, I know there were problems with the Windows installer of the last version (but now they have fixed them).
    – CarLaTeX
    Commented Dec 19, 2016 at 5:08
  • I just tested LyX 2.2.0 in my Linux with a path like ~/x x/x x.lyx and it work fine. But said that, with or without LyX, with or without LaTeX, with or without Windows, the main error is still use other than a single and short word for a directory. Sooner or later you will face some problem due to this , including forgetting or mistyping unnecessary complex paths.
    – Fran
    Commented Dec 19, 2016 at 6:34
  • 1
    In LyX settings there are some paths, put them within "...", unfortunately I don't have LyX available at the moment, you may ask the mailing list [email protected]
    – CarLaTeX
    Commented Dec 19, 2016 at 9:36
  • 1
    @user1271772 I know that one cannot always avoid spaces (I receive filenames/paths with spaces everyday) but spaces are a problem if leads to a buggy program/you to make some error/mistake that is not possible/less probable in a path without these spaces. Is a.txt b.txt just one file or two? It's not clear if spaces are allowed, right? So you/the-program need to know if it is the space is only a separator or the character of a filename (quoting, escaping, using %20, etc.). This is always correctly done? Not at all. More complexity, more errors, so simple.
    – Fran
    Commented Dec 19, 2016 at 10:59

3 Answers 3


In my case the issue got fixed after I launched MikTek Update (Admin) one time and updated all pending packages. Then reconfigured Lyx and the error was gone...


For me, the following worked:

Tools | Reconfigure

This was rattling for a minute or two, then requested a restart of Lyx. This did the trick.


Try changing the "Install missing packages on-the-fly" option to "Yes" in MiKTeX options instead of "Ask me first". This solved the problem for me on Windows 10 x64 and MiKTex 2.9

  • 1
    Welcome to TeX.SX! How does this answers the question?
    – egreg
    Commented Jan 10, 2017 at 15:36
  • @tiwoti, the option "yes" was already selected! Commented Jan 19, 2017 at 1:31
  • @tiwoti, I tried "yes", "no", and "Ask me first", and all three options lead to the same error as described in the original question. Also Reference [1] in the original question was your suggestion. Commented Jan 24, 2017 at 11:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .