blang / latex-docker

Docker-based latex compilation
MIT License
585 stars 146 forks source link

Path error on Docker for Windows from MINGW #14

Open rwb27 opened 6 years ago

rwb27 commented 6 years ago

I like to run my things from Bash on Windows, and mingw is a convenient way to do this. However, the dockercmd.sh script fails when used this way, with an error: invalid mount config for type "bind": invalid mount path: The reason for this is that mingw makes the results of pwd look unix-ey by converting the standard Windows C:\ into /c/ which, in turn, confuses Docker for Windows. The attached bash script fixes that using sed. It's not beautiful, but it works for me. I don't know if there is a reliable way to detect this issue and use the workaround automatically, but I thought I'd share it in the event that others have the problem.

I have to say, latex in Docker is fab - it has saved me a great deal of faffing around today!

I can't upload the script but I've made a gist and pasted the line below:

#!/bin/bash
docker run --rm -i --net=none -v "`pwd | sed -E 's/^\/(.)\//\1:\//'`":/data blang/latex "$@"

(I didn't seem to need the user stuff on Windows - and I'm not sure what the purpose is of the exec but that's probably just my ignorance...)

blang commented 6 years ago

Thanks for sharing your solution. I don't have windows available for tests, but i'm sure someone might have the same issue to investigate this further.

rwb27 commented 6 years ago

no worries - after a little more reading I suspect I might be able to put something together that uses the results of uname -s to tell whether it's running in mingw, and execute one line or the other accordingly. I'm happy to try to put that in a pull request if it's helpful - but given that you don't have a system to test it on, perhaps it's best just to leave this workaround in a (closed?) issue...

blang commented 6 years ago

I think an additional script like dockercmd_mingw.sh would be sufficient. I'll keep this open in case anyone wants to collaborate and verify the workaround

rwb27 commented 6 years ago

sure. I updated https://gist.github.com/rwb27/9074ac87cac705eb70d390447690b25f to switch automatically, but I agree a separate script might be easier.