Search code examples
curlheroku

How do I install Heroku using CURL on mac? Error with tar file


I am trying to install Heroku using the standalone installation method here: https://devcenter.heroku.com/articles/heroku-cli#download-and-install.

After running the command "curl https://cli-assets.heroku.com/install.sh | sh" in the terminal and inputting my login, I get an error that looks like this:

Installing CLI from https://cli-assets.heroku.com/heroku-darwin-arm.tar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   359  100   359    0     0   1768      0 --:--:-- --:--:-- --:--:--  1768
tar: Error opening archive: Unrecognized archive format

Solution

  • I don't have a macOS machine handy, but it looks like its tar doesn't support the -J parameter that would normally filter the archive through xz. The install script you're using assumes that tar supports -J if xz is found on the system:

    if [ $(command -v xz) ]; then
      URL=https://cli-assets.heroku.com/heroku-$OS-$ARCH.tar.xz
      TAR_ARGS="xJ"
    else
      URL=https://cli-assets.heroku.com/heroku-$OS-$ARCH.tar.gz
      TAR_ARGS="xz"
    fi
    

    You could modify the script to just use the code in the else clause, but the recommended way to install the Heroku CLI on macOS is to use Homebrew:

    brew tap heroku/brew && brew install heroku
    

    If that's not to your liking, feel free to simply download the tarball and extract it manually.