Homebrew-cask: QGIS fails to install

Created on 13 Nov 2015  ·  8Comments  ·  Source: Homebrew/homebrew-cask

$ brew cask install qgis
==> Satisfying dependencies
==> Installing Formula dependencies from Homebrew
matplotlib ... already installed
==> Installing Cask dependencies: gdal-framework
gdal-framework ...
already installed
complete
==> Downloading http://www.kyngchaos.com/files/software/qgis/QGIS-2.12.0-1.dmg
Already downloaded: /Library/Caches/Homebrew/qgis-2.12.0-1.dmg
==> Running installer for qgis; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
Password:
==> installer: Error - QGIS requires the Matplotlib python module (kyngchaos build).
Error: Command failed to execute!

==> Failed command:
["/usr/bin/sudo", "-E", "--", "/usr/sbin/installer", "-pkg", "#<Pathname:/opt/homebrew-cask/Caskroom/qgis/2.12.0-1/Install QGIS.pkg>", "-target", "/"]

==> Output of failed command:


==> Exit status of failed command:
#<Process::Status: pid 5199 exit 1>
$ brew info matplotlib
homebrew/python/matplotlib: stable 1.4.3, HEAD
http://matplotlib.org
/usr/local/Cellar/matplotlib/1.4.3 (2996 files, 78M) *
  Built from source
From: https://github.com/Homebrew/homebrew-python/blob/master/matplotlib.rb
==> Dependencies
Build: pkg-config ✔
Required: freetype ✔, libpng ✔, homebrew/python/numpy ✔
Optional: ghostscript ✘, homebrew/dupes/tcl-tk ✘, gtk+3 ✘, pygtk ✘, pyside ✘, pyqt ✘, pyqt5 ✘
==> Options
--with-cairo
    Build with cairo backend support
--with-ghostscript
    Build with ghostscript support
--with-gtk+3
    Build with gtk+3 support
--with-pygtk
    Build with pygtk backend support (python2 only)
--with-pyqt
    Build with pyqt support
--with-pyqt5
    Build with pyqt5 support
--with-pyside
    Build with pyside support
--with-python3
    Build with python3 support
--with-tcl-tk
    Build with tcl-tk support
--with-tex
    Build with tex support
--without-python
    Build without python2 support
--HEAD
    Install HEAD version
==> Caveats
If you want to use the `wxagg` backend, do `brew install wxpython`.
This can be done even after the matplotlib install.
If you use system python (that comes - depending on the OS X version -
with older versions of numpy, scipy and matplotlib), you may need to
ensure that the brewed packages come earlier in Python's sys.path with:
  mkdir -p /Users/username/Library/Python/2.7/lib/python/site-packages
  echo 'import sys; sys.path.insert(1, "/usr/local/lib/python2.7/site-packages")' >> /Users/username/Library/Python/2.7/lib/python/site-packages/homebrew.pth
$ brew doctor
Your system is ready to brew.

This is on El Capitan, but it looks like the issue is that QGIS expects a particular distribution of matplotlib that differs from what homebrew/python currently provides. I'm not familiar enough with the homebrew/python packaging/distribution situation to effectively troubleshoot this at the moment. It looks like the qgis formula used to depend on a casked version of matplotlib, but switched to a formula-provided version with #14043. It has also been updated since that change with #14881.

Most helpful comment

This may just be a bug with the QGIS installer having a hardcoded path. A possible (untested) workaround appears to be creating a symlink:

ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python /Library/Python/2.7/site-packages/matplotlib-override

( via http://gis.stackexchange.com/a/163512 )

All 8 comments

This may just be a bug with the QGIS installer having a hardcoded path. A possible (untested) workaround appears to be creating a symlink:

ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python /Library/Python/2.7/site-packages/matplotlib-override

( via http://gis.stackexchange.com/a/163512 )

I'd be curious to know if either @scarnecchia or @MatzFan have encountered this issue.

Update: after creating the symlink, brew cask install qgis completed successfully.

$ sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python /Library/Python/2.7/site-packages/matplotlib-override
Password:
$ brew cask install qgis
==> Satisfying dependencies
==> Installing Formula dependencies from Homebrew
matplotlib ... already installed
==> Installing Cask dependencies: gdal-framework
gdal-framework ...
already installed
complete
==> Downloading http://www.kyngchaos.com/files/software/qgis/QGIS-2.12.0-1.dmg
Already downloaded: /Library/Caches/Homebrew/qgis-2.12.0-1.dmg
==> Running installer for qgis; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.


==> installer: Package name is QGIS
==> installer: Installing at base path /
==> installer: The install was successful.
🍺  qgis staged at '/opt/homebrew-cask/Caskroom/qgis/2.12.0-1' (6 files, 182M)

This seems less than ideal, but does appear to work.
I'll let the maintainers decide whether or not to consider this issue closed.
Thanks! :smile:

Depending on the severity, we can either add a caveat, or actually execute that command automatically after install, something along the lines of

  # Symlink matplotlib so that QGIS's hardcoded path requirement is satisfied
  # Original discussion: https://github.com/caskroom/homebrew-cask/issues/15131
  postflight do
    system '/usr/bin/sudo', '-E', '--', '/bin/ln', '-s', '--', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/Library/Python/2.7/site-packages/matplotlib-override'
  end

Is this command always required for a working install? (in which case the postflight stanza shown above would be more appropriate)

My limited experience (documented above) is that the QGIS installer will not even run without the symlink. Would a postflight stanza execute before or after the package installer runs? I think it would need to run beforehand to be effective. I'm also wary of creating such symlinks without a user's explicit permission.

I'd personally be more comfortable with a caveat, but are there many other examples of caveats for dependency workarounds or do they primarily address runtime issues after the software is installed?

That could be done as a preflight stanza, which would be run before the install.

The caveat would look like:

caveats <<-EOS.undent
  #{token} requires matplotlib in a specific location. Please run the following to finish install:

    sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python /Library/Python/2.7/site-packages/matplotlib-override
EOS

I'll wait for some feedback from some of the other maintainers before we make a decision. Thanks for the detailed reporting.

cc @vitorgalvao thoughts?

I'm also wary of creating such symlinks without a user's explicit permission.

Bingo.

I'd personally be more comfortable with a caveat

And that is exactly what we should do in this case.

This may just be a bug with the QGIS installer having a hardcoded path.

Ideally, this should be fixed upstream (at which point we’ll remove the caveat).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CoolTomatos picture CoolTomatos  ·  3Comments

GeekOnGadgets picture GeekOnGadgets  ·  3Comments

tycm picture tycm  ·  3Comments

arnogues picture arnogues  ·  4Comments

jrwiegand picture jrwiegand  ·  3Comments