Invalid path exception Illegal char in SNAP 8.0

Hi everybody,

I have recently upgraded to SNAP 8.0.

I am using a python code (command to invoke the SNAP gpt command.

I get the following error:

java.nio.file.InvalidPathException: Illegal char <:> at index 50: C:\ProgramData\Anaconda3\Library\bin\gdalinfo.exeC:\Program Files\GDAL\gdalinfo.exeC:\ProgramData\Anaconda3\envs\aitlas_s2\Lib\site-packages\osgeo\gdalinfo.exe

It is obvious that java searches for all the gdalinfo.exe files (in my case three files are found), and then ‘glues’ them together in one long path without delimeter, which then throws the exception.

How can I fix this?

In version SNAP 7.0 this was not the case.

Any help will be appreciated.

have you checked if your PATH variable contains one of these entries? Maybe it was falseley added by an installation of another software.

Dear Andreas! Thank you for the quick answer.

Yes, all three GDAL paths are present in the PATH System variable, as expected.

The problem is that in gpt call of SNAP 8.0 those three paths are concatenated into one, so the error is thrown.
With SNAP 7.0 the same three GDAL paths were also present in the PATH System variable, however their concatenation did not occur, so the call of gpt was ok.

but the PATH variable only contains the paths, right?

  • C:\ProgramData\Anaconda3\Library\bin\
  • C:\Program Files\GDAL\
  • C:\ProgramData\Anaconda3\envs\aitlas_s2\Lib\site-packages\osgeo\

Sorry if I misunderstood how you meant it. That would mean that SNAP somehow makes a mistake concatenating the paths. @marpet is this possible?

Here @oana_hogoiu should have a look. I don’t know the GDAL integration.

The difference between SNAP 7.0 and 8.0 is that SNAP 7.0 used only the internal GDAL (within SNAP).
SNAP 8.0 is also capable to use an installed version of GDAL (if any compatible version found). In case of no GDAL version installed, the internal GDAL within SNAP will be used.

The cause of your problem is that several versions of GDAL are found in the PATH environment variable, and only one is allowed. (SNAP cannot decide which version to use)
The solution for you is to clean the PATH variable and let only one path towards one version of GDAL.

Oana, thanks for the answer.
It is a comon practice to have several GDALs on the computer. So for future version I suggest that the present solution is changed.
Now, when I just removed the 2 (out of 3) paths to GDAL from the PATH System variables, the change is not in the effect, since SNAP is already “built”/integrated with 3 GDALs. Is there a way to invoke a sort of re-built process of SNAP with the netBeans Platform? Or must I de-install SNAP 8.0 and install it again?

No, there is no need to re-install SNAP 8.0 again.
What you can do is to close SNAP, delete all cache, and restart SNAP.
For cache delete, try to clean:
C:\Users\[username]\AppData\Roaming\SNAP or C:\Users\[username]\AppData\Local\SNAP

Also, from Tools -> Options -> S2TBX, you can choose which GDAL shall be used (in your case maybe the problem will solve by just using the internal GDAL - first option):

And to clarify:

True, but only one should be available at one time, in PATH.

No, SNAP has only one internal GDAL, the default option is to use the user installed GDAL version, you had 3 declared in PATH, but this has no relation with the GDAL that SNAP was build with.

1 Like

Thany you!
For me it worked only the first of your suggestions: to clean the PATH variable of paths to all (!) GDAL versions. This results in the fact that the internal GDAL within SNAP is used.

1 Like

Yes, in this case no installed GDAL is detected and the internal one is used by SNAP.