Opened 12 years ago

Closed 12 years ago

#1803 closed defect (fixed)

GRASS 6.4.3RC1 on Win 7: grass64.bat fails due to UNIX line endings in Init.bat

Reported by: msieczka Owned by: grass-dev@…
Priority: critical Milestone: 6.4.3
Component: Startup Version: 6.4.3 RCs
Keywords: Init.bat, CRLF, wingrass Cc: grass-dev@…
CPU: x86-64 Platform: MSWindows 7

Description (last modified by martinl)

There's a following error at GRASS 6.4.3RC1 startup in text mode on Win 7 64bit:

C:\>"C:\Program Files (x86)\GRASS GIS 6.4.3RC1\grass64.bat" -text
The system cannot find the batch label specified - aftertextcheck

The problem is in the etc\Init.bat where the "aftertextcheck" label is used - looks like Windows expects "\r\n" at the end of the label name rather than "\n".

Are the Windows builds done on Linux? If so, I guess the root cause is eol-style=native on lib/init/init.bat in the GRASS repo. The solution would be to set eol-style=CRLF, or maybe to tweak the makefile to run tr/unix2dos/... on etc/Init.bat.

Opinions?

There are plenty of *.bat with LF instead of CRLF in the GRASS installation dir. Shouldn't they all have CRLF line endings?:

$ cd '/c/Program Files (x86)/GRASS GIS 6.4.3RC1'
$ find . -type f -iname '*.bat' -print0 | xargs -0 grep -Ulv $'\r' | wc -l
112

Change History (18)

comment:1 by martinl, 12 years ago

Description: modified (diff)

in reply to:  description comment:2 by martinl, 12 years ago

Description: modified (diff)

Replying to msieczka:

Are the Windows builds done on Linux? If so, I guess the root cause

winGRASS are built on Windows, of course - in MinGW/MSys environment.

comment:3 by martinl, 12 years ago

I don't know why but original description has been modified (I just clicked on 'reply'). Now should be back. And my answer:

Are the Windows builds done on Linux? If so, I guess the root cause

winGRASS are built on Windows, of course - in MinGW/MSys environment.

comment:4 by msieczka, 12 years ago

I assume that the svn checkout from GRASS repo is done on Windows too.

In that case, lib/init/init.bat (having eol-style=native) should have CRLF line endings after an svn checkout on Win. So why does etc/Init.bat (made from lib/init/init.bat during the build) have LF instead?

And BTW - should the other 111 *.bat have LF rather than CRLF like they do?

Same issue is present in GRASS 6.4.3RC1 provided by the OSGeo4W installer.

in reply to:  description comment:5 by neteler, 12 years ago

Replying to msieczka:

There's a following error at GRASS 6.4.3RC1 startup in text mode on Win 7 64bit:

C:\>"C:\Program Files (x86)\GRASS GIS 6.4.3RC1\grass64.bat" -text
The system cannot find the batch label specified - aftertextcheck

The problem is in the etc\Init.bat where the "aftertextcheck" label is used - looks like Windows expects "\r\n" at the end of the label name rather than "\n".

It is surprising that this has never been reported before.

Any CRLF expert here?

in reply to:  4 comment:6 by martinl, 12 years ago

Replying to msieczka:

I assume that the svn checkout from GRASS repo is done on Windows too.

In that case, lib/init/init.bat (having eol-style=native) should have CRLF line endings after an svn checkout on Win. So why does etc/Init.bat (made from lib/init/init.bat during the build) have LF instead?

I have changed eol-style for init.bat to CRLF in r54365 (devbr6).

The source code in devb6 contains 24 bat files (other bat files are generated during compilation process - for shell scripts).

find . -name '*.bat'
./mswindows/external/rbatch/Rversions.bat
./mswindows/external/rbatch/Rtidy.bat
./mswindows/external/rbatch/rterm.bat
./mswindows/external/rbatch/Rtools.bat
./mswindows/external/rbatch/Rcmd.bat
./mswindows/external/rbatch/RguiStart.bat
./mswindows/external/rbatch/movedir.bat
./mswindows/external/rbatch/#Rscript.bat
./mswindows/external/rbatch/Stangle.bat
./mswindows/external/rbatch/copydir.bat
./mswindows/external/rbatch/Rgui.bat
./mswindows/external/rbatch/RtoolsVersion.bat
./mswindows/external/rbatch/Sweave.bat
./mswindows/external/rbatch/R.bat
./mswindows/external/rbatch/Rscript.bat
./mswindows/env.bat
./mswindows/osgeo4w/postinstall.bat
./mswindows/osgeo4w/msys.bat
./mswindows/osgeo4w/preremove.bat
./scripts/windows_launch.bat
./gui/scripts/windows_launch.bat
./gui/tcltk/gis.m/gis.m.bat
./lib/init/grass-run.bat
./lib/init/init.bat

comment:7 by hamish, 12 years ago

did the work-around work?

in reply to:  7 ; comment:8 by msieczka, 12 years ago

Replying to hamish:

did the work-around work?

It was not applied to releasebranch_6_4.

Is there any reason that prevents us from setting eol-style to CRLF for *.bat files once and for all to avoid such issues in the future?

comment:9 by msieczka, 12 years ago

Promoting to blocker, per #1890.

in reply to:  8 ; comment:10 by neteler, 12 years ago

Replying to msieczka:

Replying to hamish:

did the work-around work?

It was not applied to releasebranch_6_4.

Please update grass-addons/tools/module_svn_propset.sh to do it properly. Then it becomes an easy job.

in reply to:  10 comment:11 by hamish, 12 years ago

Keywords: wingrass added

Replying to neteler:

Please update grass-addons/tools/module_svn_propset.sh to do it properly. Then it becomes an easy job.

done, & all .bat files in main svn now updated in r55154,5,6.

I notice have this unchecked-in change for grass6x/lib/init/init.bat:

Index: lib/init/init.bat
===================================================================
--- lib/init/init.bat	(revision 55154)
+++ lib/init/init.bat	(working copy)
@@ -142,9 +142,9 @@
 
 set PYTHONPATH=%PYTHONPATH%;%GISBASE%\etc\python;%GISBASE%\etc\wxpython
 
-python "%GISBASE%/etc/wxpython/gis_set.py"
+"%GRASS_PYTHON%" "%GISBASE%/etc/wxpython/gis_set.py"
 if %errorlevel% == 2 goto exitinit
-python "%GISBASE%/etc/wxpython/wxgui.py"
+"%GRASS_PYTHON%" "%GISBASE%/etc/wxpython/wxgui.py"
 
 goto exitinit
 

any thoughts?

Hamish

comment:12 by hamish, 12 years ago

Retesting with the 6.4.3svn r55185 nightly build; the svn prop change didn't help.

I assume that's because the Init.bat script is not copied, it is made from init.bat(?).

note that msys nicely provides unix2dos.exe, if we need it at build or install time.

Once resaving Init.bat with DOS newlines, "GRASS Command Line" in the cmd.exe window starts, but after esc-enter an error message pops up saying "set_data.exe has stopped working (segfault afaict "APPCRASH") do you want to check for an online solution or close the program?". If you press cancel you get the usual GRASS welcome text but no ascii art, and g.gisenv all seems to be ok.

not sure where to go from here, but the nightly build scripts?

Hamish

in reply to:  12 ; comment:13 by neteler, 12 years ago

Replying to hamish:

Retesting with the 6.4.3svn r55185 nightly build; the svn prop change didn't help.

I assume that's because the Init.bat script is not copied, it is made from init.bat(?).

note that msys nicely provides unix2dos.exe, if we need it at build or install time.

Wouldn't it be sufficient then to add a unix2dos.exe call in:

http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/lib/init/Makefile#L107

?

in reply to:  13 comment:14 by hamish, 12 years ago

Replying to neteler:

Wouldn't it be sufficient then to add a unix2dos.exe call in:

http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/lib/init/Makefile#L107

?

attempted in r55296.

Hamish

in reply to:  13 ; comment:15 by hellik, 12 years ago

Replying to neteler:

Wouldn't it be sufficient then to add a unix2dos.exe call in:

http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/lib/init/Makefile#L107

tested here with

GRASS version: 6.4.3svn                                                         
GRASS SVN Revision: 55262                                                       
GIS Library Revision: 50937 (2012-02-25)                                        
GDAL/OGR: 1.9.2                                                                 
PROJ4: Rel. 4.8.0, 6 March 2012                                                 
Python: 2.7.2                                                                   
wxPython: 2.8.12.1                                                              
Platform: Windows-7-6.1.7601-SP1 (OSGeo4W)     

"GRASS 6.4.3svn GUI" start without any problem, but "GRASS 6.4.3svn Command Line" is the problem.

unix2dos C:\OSGeo4W\apps\grass\grass-6.4.3svn\etc\Init.bat helps to start by "GRASS 6.4.3svn Command Line", by maybe other files affected...

Helmut

in reply to:  15 ; comment:16 by martinl, 12 years ago

Replying to hellik:

Replying to neteler:

Wouldn't it be sufficient then to add a unix2dos.exe call in:

http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/lib/init/Makefile#L107

tested the last build (no.517) and GRASS 6.5 CLI starts. Please backport to relbr64.

in reply to:  16 ; comment:17 by neteler, 12 years ago

Replying to martinl:

tested the last build (no.517) and GRASS 6.5 CLI starts. Please backport to relbr64.

Done in r55304.

in reply to:  17 comment:18 by hellik, 12 years ago

Resolution: fixed
Status: newclosed

Replying to neteler:

Replying to martinl:

tested the last build (no.517) and GRASS 6.5 CLI starts. Please backport to relbr64.

Done in r55304.

tested and works.

closing ticket, reopen if needed.

Helmut

Note: See TracTickets for help on using tickets.