LyX: "Directory path to the document cannot contain spaces" when exporting to PDF

4,801

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...

Share:
4,801
user1271772
Author by

user1271772

Updated on August 01, 2022

Comments

  • user1271772
    user1271772 over 1 year

    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 ?

    • Timothy Truckle
      Timothy Truckle almost 7 years
      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.
    • CarLaTeX
      CarLaTeX almost 7 years
      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).
    • Fran
      Fran almost 7 years
      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.
    • user1271772
      user1271772 almost 7 years
      @TimothyTruckle: I have the Ubuntu Bash in my Windows 10 (which is an analog of Linux's Wine program, meaning I can run linux software in my Windows 10). Are you suggesting that I re-install the entire LyX, but this time the Linux version of LyX in my Windows 10 Ubuntu Bash ?
    • user1271772
      user1271772 almost 7 years
      @CarLaTeX: What do you mean by adding "..." ? My file path has spaces in it, and I want to export to PDF. How do I add the quotes in Windows 10? I am using the LyX GUI, not a command line LyX.
    • CarLaTeX
      CarLaTeX almost 7 years
      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]
    • user1271772
      user1271772 almost 7 years
      @Fran: Spaces in file names and directory paths are not a problem. It is also not controllable, for example if you are working on a company document that has spaces in it, or if you're working in Google Drive or Box Sync, where the directory that is syncing has spaces in it. No, the possibility of "forgetting" or "mistyping" has no meaning in this discussion. You can mistype any file path regardless of whether or not there's a space. And even if that possibility exists, changing every file path so that there are no spaces, is not a solution to this problem.
    • Fran
      Fran almost 7 years
      @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.
    • user1271772
      user1271772 almost 7 years
      @Fran: Great example with the a.txt b.txt. It is true that spaces should be avoided if possible. If there is a choice between using a space and an underscore, I would choose the underscore. Most of my file's are actually named using CamelCase. However, for a company file with a space in it, in the folder called "Google Drive", there is no choice, and the question I am asking is how to deal with this situation when there's no choice, not for general advice on how to name my files.
    • Fran
      Fran almost 7 years
      @user1271772 As comments/answers could help to others, inevitably we tend to make general advices ;) In your case, no idea, but I would try pdflatex '$$i' or pdflatex "$$i" instead of pdflatex $$i in Preferences > File handling > Converters.
    • Timothy Truckle
      Timothy Truckle almost 7 years
      @user1271772 "I have the Ubuntu Bash in my Windows 10" which still depends on the file system handling API of w10 which obviously changed. The VM solution would avoid that (or at least move the problem to the VM supplier who may be more focussed on stuff like that).
    • user1271772
      user1271772 almost 7 years
      @Fran: I have gone to Preferences -> File handling -> Converters, and I assumed it is "LaTeX (pdflatex) -> PDF (pdflatex)" that I should change. I changed << Converter: pdflatex $$i >> to << Converter: pdflatex "$$i" >> and also tried '$$i', but when I try to export to PDF (pdflatex) when the LyX file is open, it does not work. I have a feeling this might have to do with the fact that I changed the settings for "LaTeX (pdflatex) -> PDF (pdflatex)". Did I make the correct change?
    • user1271772
      user1271772 almost 7 years
      @TimothyTruckle: I could have sword that LyX was producing PDFs like normal, on my Windows 10 prior to setting up the Ubuntu Bash. I de-selected the option to have a bash now, but the problem persists. When you say "API of w10 which obviously changed", do you mean changed since Windows 8? Or changed since I set up the Ubuntu Bash ? so your recommendation is for me to install VirtualBox, then what do I do with it? I have to re-install LyX? Or I can just use virtualBox to run LyX and export the PDF?
    • Fran
      Fran almost 7 years
      @user1271772 Bad luck! I guessed that the bug could be $$i passed as more than one file. Sorry, then return to the original pdflatex $$i. In my Linux what is compiled really is not the original this file.tex, but this_file.tex (no spaces) in a temporal path as /tmp/lyx_tmpdir.wvbEYbp18598/lyx_tmpbuf0. Have you something similar in C:\TEMP? (if still exist in W10).
    • user1271772
      user1271772 almost 7 years
      @TimothyTruckle: I wonder what to do in order to produce LyX files from my Windows 10 machine. If I install VirtualBox, what do I do with it? Do I have to re-install LyX all over again (linux version instead of Windows 10 version) ?
    • Timothy Truckle
      Timothy Truckle almost 7 years
      @user1271772 "Do I have to re-install LyX all over again (linux version instead of Windows 10 version)" You get rid of the Windows version, install and use the linux version in your VB. The good thing about that is: You linux-LyX will keep updated automatically with the linux software management (Just as the LaTeX distro does), and you have not to worry about that next time you reinstall your windows (for any reason), you just copy the VB to the new installation.
    • user1271772
      user1271772 almost 7 years
      @TimothyTruckle: I have installed VirtualBox. I clicked "New" and then it asks me which Linux to install. There's a lot of options. Also, I know some of these are not free linux distributions. What should I choose? Can I click on Ubunut or Red Hat even though I don't have the software?
    • Timothy Truckle
      Timothy Truckle almost 7 years
      as as new user to VB you better get a preinstalled guest. As a windows user you may like Kubuntu (a version of ubuntu with the KDE-desktop which is quite close to windows7) download from here: virtualboximages.com/VirtualBox+Kubuntu+VDIs (takes time) In the menu look out for Muon Discover, open it and search for texlive or latex
    • user1271772
      user1271772 almost 7 years
      @TimothyTruckle The most recent version of Kubuntu on that page you sent is from 2014. Why so long ago? Also I thought Ubuntu is not free. How is it that I'm doing this for free? What exactly am I doing here? Can you please explain to me what VirtualBox is, and what I'm going to be doing? I have indeed tried reading about it online, but the concept of a "virtual machine" is new to me.
    • user1271772
      user1271772 almost 7 years
      @TimothyTruckle: I clicked on the most recent Kubuntu, and then clicked "Free Download" but then after waiting, got the page "This site cannot be reached". This link was here: download.virtualboximages.com/VMs/Kubuntu/15.04/…
    • user1271772
      user1271772 almost 7 years
      Same happens for the most recent regular Ubuntu: 142.4.214.205/VMs/Ubuntu/15.04/…
    • Admin
      Admin over 6 years
      On a Windows machine, there is almost certainly a data partition, usually named D:\. Can you save to that partition, which does not have any spaces in its path? If so, you can later move it to your home directory, if desired.
  • egreg
    egreg almost 7 years
    Welcome to TeX.SX! How does this answers the question?
  • user1271772
    user1271772 almost 7 years
    @tiwoti, the option "yes" was already selected!
  • user1271772
    user1271772 almost 7 years
    @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.