yochju / latex-makefile

Automatically exported from code.google.com/p/latex-makefile
Other
0 stars 0 forks source link

Cygwin path with space #154

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If building from within cygwin on a path that has a space in it such as 
C:\Users\MyName\My Documents\latex. cygpath does not escape the space (as it 
used to), causing the makefile to break. 

I tried to mitigate this by piping cygpath through a sed call s/ /\\ /g to 
espace the space, but this causes the makefile to hang.

Original issue reported on code.google.com by ChrisMar...@gmail.com on 20 Mar 2012 at 5:39

GoogleCodeExporter commented 9 years ago
Doesn't cygpath have some command-line options that allow you to specify how it 
works?  It may be that we just have the wrong options set.

http://cygwin.com/cygwin-ug-net/using-utils.html#cygpath

For example, we might consider using -m instead of -u.  I don't know if that 
will escape spaces or not, but it might.

Out of curiosity, what exactly were you doing to pipe cygpath through sed?  I 
can probably help you with that.

Original comment by shiblon on 22 Mar 2012 at 6:34

GoogleCodeExporter commented 9 years ago
Cygpath has a variety of options, but none that escape spaces. The dos 'short' 
flag produces tildes 

$ cygpath -d "`pwd`"
C:\users\chris\MYDOCU~1\masters

but that causes the makefile to error out later with the error:

$ make
marsh_thesis.d:3: *** target pattern contains no `%'.  Stop.

cygpath -m doesn't escape spaces.

for sed:
on lines 786 - 788 is the define for path-norm. I modified it to:
define path-norm
$(if $(USE_CYGPATH),$(shell $(CYGPATH) -u "$1" | sed 's/ /\\ /g'),$1)
endef

My makefile scripting is not at a level where I'm 100% sure I know exactly how 
this function of sorts works. There might have been some side effects of what I 
did. Regardless, make hangs and I have to kill it. 

I then made a script cygpath2.sh that wrapped the call to cygpath with the sed 
pipe (changing the cygpath define accordingly in the makefile). However, the 
makefile then stops with the error
Makefile:2955: *** multiple target patterns.  Stop.

Original comment by ChrisMar...@gmail.com on 22 Mar 2012 at 4:05

GoogleCodeExporter commented 9 years ago
The reason the makefile hangs, I believe, is at least one, maybe two things.

First, you didn't use -e for your sed expression:

sed -e 's/ /\\ /g'

That will probably fix it.

But if it is still wrong, which might happen, you may need to escape the 
backslashes again:

sed -e 's/ /\\\\ /g'

Let me know how those go :)

Original comment by shiblon on 23 Mar 2012 at 10:10

GoogleCodeExporter commented 9 years ago
Thanks for the suggestions. Unfortunately, they didn't help. Both variants you 
suggest still results in make hanging. I've copied the error below. 
$ make
NOTE: You may ignore warnings about the following files:

     marsh_thesis.d

Makefile:2742: marsh_thesis.d: No such file or directory
= marsh_thesis.tex --> marsh_thesis.d marsh_thesis.pdf.1st.make (0-1) =
      2 [main] make 7824 sig_send: wait for sig_complete event failed, signal 6, rc 258, Win32 error 0

Interestingly, make clean now runs no problem with sed -e 's/ /\\ /g', which 
suggests we are close to a solution.

Original comment by ChrisMar...@gmail.com on 23 Mar 2012 at 4:30

GoogleCodeExporter commented 9 years ago
Unfortunately, I just don't have enough information to even guess at what is 
wrong.  Typically, "make" hangs when one of its subprocesss expects input, but 
doesn't get any.

This is almost always sed's fault.  If sed doesn't get a filename, it goes into 
pipe mode, and it expects input on stdin.  If it gets neither, it sits there 
waiting for a response.

So, one thing you can try when make hangs is to type something, then hit 
CTRL-D, and see what kinds of errors pop out.

Original comment by shiblon on 26 Mar 2012 at 8:52

GoogleCodeExporter commented 9 years ago
I've discovered a few things: 

I didn't have the newest make from cygwin. As well, the newest make doesn't 
have DOS support.
http://geant4.web.cern.ch/geant4/support/windows_note.shtml

Using this version
http://sites.rwalker.com/cygwin/
has stopped make from hanging. 

The sed call now works, but instead of escaping with a \, it escapes with a /, 
resulting in a funny path such as [...]/My/ Documents/[...]. Using -d instead 
of -u with no sed call, seems to work. However cygpath complains about the 
funny paths as for somereason the spaces are replaced with / . Is there 
somewhere in the makefile where you do this? 

The pdf created with -d seems to be properly generated, with all sections and 
bibtex properly created.

Original comment by ChrisMar...@gmail.com on 26 Mar 2012 at 7:26

GoogleCodeExporter commented 9 years ago
Ah, I see what's happening.

The cygpath invocation is enforcing unix path format, so it's switching 
backslashes to forward slashes.  Does it work without the sed invocation?  It 
does for others...

There are several other modes, like -w and -m that might be worth trying.

The problem is that if you use a backslash-delimited path format, all of your 
own backslashes are going to be interpreted not as space escapes, but as 
delimiters.  So, it's not the makefile doing this, it's cygwin (and maybe 
cygwin's version of make).

I think you want to remove the sed call and just use -u.

Original comment by shiblon on 27 Mar 2012 at 7:50

GoogleCodeExporter commented 9 years ago
Just -u doesn't work. For some reason, the space in the cygpath generated path 
is getting replaced with a /. This is not cygwin behavior, or at least not one 
I've encountered before. For the moment I've just renamed My Documents to 
Documents :) Now -u works ok.

Original comment by ChrisMar...@gmail.com on 27 Mar 2012 at 4:52