Bug report #5345

Problems with PATH-Variables in msys.bat and OSGeo4W

Added by Stefan Ramme about 12 years ago. Updated over 10 years ago.

Affected QGIS version:1.7.4 Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:up/downstream
Crashes QGIS or corrupts data:No Copied to github as #:15045


Under Windows-OS the batch files "msys.bat" and "OSGeo4W.bat" experience problems when path-variables to executables called within the batch file contain whitespace like "C:\\Program Files\\Quantum Gis Wroclaw" - which is the case in all Windows installations of QGis. Execution of batch file terminates with "C:\\Program" could not be found...

Might have s.th. to do with coding the path to the executables in a variable (not hardcoded).

Execution of batch file msys.bat worked without problems in 1.7.3
Execution of batch file for calling Grass works without problems in 1.7.4


#1 Updated by Paolo Cavallini about 12 years ago

  • Target version changed from Version 1.7.4 to Version 1.8.0

#2 Updated by Jürgen Fischer about 12 years ago

  • Resolution set to upstream

The standalone installer repackages GRASS (and QGIS) from OSGeo4W. Please check if GRASS in OSGeo4W has the same issues (which it should) and if so open a ticket there. The default there is C:\\OSGeo4W so to verify, so you should change that to e.g. C:\\Program Files\\OSGeo4W to replicate.

#3 Updated by Jürgen Fischer about 12 years ago

  • Subject changed from Problems with PATH-Variables in mysy.bat and OSGeo4W (Windows) to Problems with PATH-Variables in msys.bat and OSGeo4W

#4 Updated by Paolo Cavallini over 11 years ago

  • Target version changed from Version 1.8.0 to Version 2.0.0

#5 Updated by Andre Joost over 11 years ago

After testing a bit around with quotation marks, I made the following changes to osgeo4w.bat:

@echo off
rem Root OSGEO4W home dir to the same directory this script exists in
set OSGEO4W_ROOT=%~dp0
rem Convert double backslashes to single
echo. & echo OSGEO4W home is %OSGEO4W_ROOT% & echo.

set _path=%OSGEO4W_ROOT%bin
call "%OSGEO4W_ROOT%bin\\addpath.bat" _path
set _path=

rem Add application-specific environment settings
for %%f in ("%OSGEO4W_ROOT%\\etc\\ini\\*.bat") do call "%%f" 

rem List available o4w programs
rem but only if osgeo4w called without parameters
rem if [%1]==[] call o-help
@echo on

@if [%1]==[] (cmd.exe /k o-help) else (cmd /c "%*")

and for o-help.bat:
@echo off
:: Osgeo4w Quick Help -- report available executables in o4w bin directory
:: 2012-02(Feb)-06, Matt Wilkie <[email protected]>
:: License: Open source MIT, http://www.opensource.org/licenses/mit-license
setlocal enabledelayedexpansion

  echo.                   -={ OSGeo4W Shell Commands }=-
  if ["%OSGEO4W_ROOT%"]==[] goto :NoEnv

      rem Generate executables list
      pushd %OSGEO4W_ROOT%\\bin
      echo.                     > "%temp%\\o-help-list.txt" 
      dir /d *.exe |find ".exe" >>"%temp%\\o-help-list.txt" 
      echo.                     >>"%temp%\\o-help-list.txt" 
      dir /d *.bat |find ".bat" >>"%temp%\\o-help-list.txt" 

      rem Strip extensions and report just names
      rem c.f. http://ss64.com/nt/syntax-replace.html
      for /f "usebackq delims=?" %%g in ("%temp%\\o-help-list.txt") do (
        set _s=%%g
        set _s=!_s:.exe=!
        set _s=!_s:.bat=!
        echo.       !_s!
      del "%temp%\\o-help-list.txt" 

      rem Report gdal version, if present
      for %%g in (gdalinfo.exe) do if not ["%%~dp$PATH:g"]==[] gdalinfo --version

  goto :EOF

  echo    ERROR: OSGEO4W_ROOT is not set

The previous error does not come up, but gdalinfo crashes in the end.

#6 Updated by Andy Harfoot over 11 years ago

I have independently applied the same corrections to osgeo4w.bat and o-help.bat proposed by Andre Joost and can confirm that these modifications correct the errors for both the standalone install ( and the OSGeo4W package based install (GDAL 1.9.1-2) on Win7.

I have raised a ticket duplicating most of this on the OSGeo4W trac (http://trac.osgeo.org/osgeo4w/ticket/315)

#7 Updated by Giovanni Manghi over 10 years ago

  • Resolution changed from upstream to up/downstream
  • Status changed from Open to Closed

The ticket filed upstream has been fixed, I guess this can be closed.

Also available in: Atom PDF