Install snapcraft on macOS

On Apple macOS Yosemite (or later), Snapcraft 3 can be installed via Homebrew and used to build snaps within the macOS environment.

Prerequisites:

To install snapcraft, open 'Terminal` and enter the following:

$ brew install snapcraft

When the process completes, the snapcraft command will be installed and ready to go. See Snapcraft overview for help getting started.

I’ve followed the above instructions but the brew install snapcraft is failing at the last step with the error:

Updating Homebrew...
==> Installing dependencies for snapcraft: python, lz4, lzo and squashfs
Error: python is already installed from !
Please `brew uninstall python` first."

I had Python 3 installed in /usr/local/bin/python and it is version 3.7 - why should I need to uninstall it? Actually somehow my python3 is no longer available, so its even worse, something has broken. And even if I try to uninstall python as suggested, I get the error:

$ brew uninstall python
Error: Refusing to uninstall /usr/local/Cellar/python/3.7.0
because it is required by httpie, libxml2, libxslt and pipenv, which are currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies python

Any advice on installing snapcraft on Mac OS Mojave would be appreciated.

Update: I repaired my Python (which was set on 3.7.0) to Python 3.7.3 and tried again using

brew upgrade python3
brew install snapcraft

and snapcraft finally installed. Perhaps snapcraft didn’t like that I had an older Python 3 installed or something. I have had these brew versions installed:

/usr/local/Cellar/python/3.6.4_4 (9,009 files, 152.6MB)
  Built from source on 2018-03-13 at 22:29:29
/usr/local/Cellar/python/3.7.0 (4,961 files, 105.2MB)
  Poured from bottle on 2019-01-09 at 11:28:53
/usr/local/Cellar/python/3.7.1 (3,887 files, 60.1MB)
  Poured from bottle on 2018-12-05 at 20:55:47

and had switched from 3.7.1 to 3.7.0, using commands like

brew switch python3 3.7.0
brew switch python3 3.7.1

Anyway, am now on Python 3.7.3 whether I like it or not, and snapcraft is installed ok.

Thanks for letting us know, and for the detailed explanation. We’ll investigate the issue and update the instructions as necessary.

For reference, I’ve just tried reinstalling on Sierra (Python 3.7.2 grabbed as a brew dependency) and it’s working ok.

@degville @sergiusens I noticed that the homebrew formula (official way to install snapcraft on macOS) is still stuck on snapcraft 3.3. Likely because it does not simply reference the tagged source code snapshot on GitHub, but rather a “release” version on pythonhosted.org.

I’d be glad to bump the homebrew formula myself and point it to the release archives GitHub, but wanted to ask first.

1 Like

If you are upto moving away from the pypi released version to the autogenerated github source tarball, I would be more than happy to support that.

If not, thanks for the reminder to get this up to date.

@sergiusens https://github.com/Homebrew/homebrew-core/pull/43191

I used the 3.7.2 tag with brew bump-formula-pr, hope it’ll work like the packaged version from pythonhosted :blush:

FYI: I bumped into missing package errors in Jenkins’ test runs, added two follow-up commits which hopefully resolve things. Here’s the current status.

PR got merged tonight, 3.7.2 is available via homebrew: https://github.com/Homebrew/homebrew-core/blob/master/Formula/snapcraft.rb

FYI @sergiusens et al: Just submitted https://github.com/Homebrew/homebrew-core/pull/44229 to bump the formula to 3.8. Thanks for the continued great work!

1 Like

Hi, I got this message after installed snapcraft with Brew on Mac OS 12.0.1 Monterey :slight_smile:

    $ snap install easy-installer
    Interacting with snapd is not yet supported on darwin.
    This command has been left available for documentation purposes only.

Do you know how to interact with snapd on Darwin ? Is that possible ? I didn’t find any trace of /snap/bin/ /var/lib/snapd/ directories