Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cygwin path with space #167

Open
shiblon opened this issue Feb 24, 2016 · 8 comments
Open

Cygwin path with space #167

shiblon opened this issue Feb 24, 2016 · 8 comments

Comments

@shiblon
Copy link
Owner

shiblon commented Feb 24, 2016

Originally reported on Google Code with ID 154

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.

Reported by ChrisMarsh.c2 on 2012-03-20 17:39:24

@shiblon
Copy link
Owner Author

shiblon commented Feb 24, 2016

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.

Reported by shiblon on 2012-03-22 06:34:41

@shiblon
Copy link
Owner Author

shiblon commented Feb 24, 2016

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.


Reported by ChrisMarsh.c2 on 2012-03-22 16:05:34

@shiblon
Copy link
Owner Author

shiblon commented Feb 24, 2016

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 :)

Reported by shiblon on 2012-03-23 10:10:30

@shiblon
Copy link
Owner Author

shiblon commented Feb 24, 2016

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.

Reported by ChrisMarsh.c2 on 2012-03-23 16:30:40

@shiblon
Copy link
Owner Author

shiblon commented Feb 24, 2016

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.

Reported by shiblon on 2012-03-26 08:52:51

@shiblon
Copy link
Owner Author

shiblon commented Feb 24, 2016

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.

Reported by ChrisMarsh.c2 on 2012-03-26 19:26:26

@shiblon
Copy link
Owner Author

shiblon commented Feb 24, 2016

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.

Reported by shiblon on 2012-03-27 07:50:01

@shiblon
Copy link
Owner Author

shiblon commented Feb 24, 2016

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.

Reported by ChrisMarsh.c2 on 2012-03-27 16:52:37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant