Skip to content

Instantly share code, notes, and snippets.

@ateucher
Last active November 1, 2019 05:37
Show Gist options
  • Save ateucher/15d25169a5f60a6dadee8cf912861ee6 to your computer and use it in GitHub Desktop.
Save ateucher/15d25169a5f60a6dadee8cf912861ee6 to your computer and use it in GitHub Desktop.
Install SAGA GIS on a Mac (2019-10-30)
# If you haven't installed homebrew, see some instructions here:
# https://github.com/bcgov/envreportutils/wiki/Macbook-Pro-Setup-for-Data-Science-at-EnvReportBC#homebrew
# These have not been tested on macOS Catalina, but the Mojave instructions _should_ work.
# If you run into issues, this looks like it might be helpful:
# https://medium.com/faun/macos-catalina-xcode-homebrew-gems-developer-headaches-cf7b1edf10b7
# The osgeo homebrew tap is in a bit of a mess, so `brew install saga-gis` doesn't work (as of 2019-10-30).
# This is because SAGA dependencies have been updated, but they haven't updated the brew formula for SAGA itself.
# Same goes for QGIS; and now that there is a fully self-contained signed installer, I recommend that over heomebrew for QGIS
# (https://qgis.org/en/site/forusers/download.html)
# The following worked for me for SAGA:
# if you have only just installed homebrew or don't have these installed don't run this line:
brew unlink osgeo-gdal osgeo-proj osgeo-libspatialite osgeo-gdal-python
# Then run:
brew install https://raw.githubusercontent.com/OSGeo/homebrew-osgeo4mac/f6e7b27c7485afbdc5a8d9844231fd2e64f02659/Formula/osgeo-gdal.rb
brew install https://raw.githubusercontent.com/OSGeo/homebrew-osgeo4mac/b37f82142e347c293cf0b7992f6187d40116b2ca/Formula/osgeo-proj.rb
brew install https://raw.githubusercontent.com/OSGeo/homebrew-osgeo4mac/27f4ac2bc4056750307cee1b7a6abb9e33c846dd/Formula/osgeo-libspatialite.rb
brew install https://raw.githubusercontent.com/OSGeo/homebrew-osgeo4mac/de5db18027bc37cd3bb0d4be07f59fdc8fe55df9/Formula/osgeo-gdal-python.rb
brew install saga-gis --with-app
# The SAGA command-line tools will be installed, and the GUI will too at: /usr/local/opt/osgeo-saga/
# You can make the SAGA GUI available in your Applications folder by running:
ln -Fs `find $(brew --prefix) -name "SAGA.app"` /Applications/SAGA.app
# In R, RSAGA::rsaga.env() was able to find the SAGA installation, so that seems like a good sign!
@DonMorgan
Copy link

Running Catalina Mac OS10.15 seems to be a challenge to load SAGA, both osgeo-gdal and osgeo-libspatialite.rb from above failed. Catalina has dropped 32bit support seems to be the issue and the ports haven't quite caught up to the new OS release.

@ateucher
Copy link
Author

@DonMorgan can you post the full error message you get when you try to run

brew install https://raw.githubusercontent.com/OSGeo/homebrew-osgeo4mac/f6e7b27c7485afbdc5a8d9844231fd2e64f02659/Formula/osgeo-gdal.rb

@j-krogh
Copy link

j-krogh commented Oct 31, 2019

I had errors withe security which I was able to work through and got to the last step above before getting this error.

==> Installing osgeo/osgeo4mac/osgeo-saga --with-app
==> Downloading https://downloads.sourceforge.net/project/saga-gis/SAGA%20-%207/SAGA%20-%207.2.0/saga-7.2.0.tar.g
==> Downloading from https://ayera.dl.sourceforge.net/project/saga-gis/SAGA%20-%207/SAGA%20-%207.2.0/saga-7.2.0.t
######################################################################## 100.0%
==> autoreconf -i
==> ./configure --prefix=/usr/local/Cellar/osgeo-saga/7.2.0_1 --disable-openmp --disable-libfire --enable-shared 
Last 15 lines from /Users/jkrogh/Library/Logs/Homebrew/osgeo-saga/02.configure:
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '590847861' is supported by ustar format... no
checking whether GID '1839645156' is supported by ustar format... no
checking how to create a ustar tar archive... none
checking whether the C++ compiler works... no
configure: error: in `/private/tmp/osgeo-saga-20191031-31744-1rsg7i8/saga-7.2.0':
configure: error: C++ compiler cannot create executables
See `config.log' for more details

If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
  https://github.com/osgeo/homebrew-osgeo4mac/issues

These open issues may also help:
Can't build osgeo-saga from source https://github.com/OSGeo/homebrew-osgeo4mac/issues/1270

@ateucher
Copy link
Author

ateucher commented Nov 1, 2019

Thanks @j-krogh... I'm not sure if you would have got this far without it, but just to be sure, do you have XCode command-line tools installed (xcode-select --install)? And/or try xcode-select --reset as suggested here?

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