Skip to content

Instantly share code, notes, and snippets.

@ascendbruce
Last active August 13, 2020 19:16

Revisions

  1. ascendbruce revised this gist May 14, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -35,7 +35,7 @@ which psql
    ```
    3. restart your Mac

    https://stackoverflow.com/questions/7975556/how-to-start-postgresql-server-on-mac-os-x
    ref: https://stackoverflow.com/questions/7975556/how-to-start-postgresql-server-on-mac-os-x

    # try 1: switch to old brew

  2. ascendbruce revised this gist May 14, 2018. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,21 @@ psql --version
    which psql
    ```

    # try 0: restart servers

    1. restart with homebrew
    ```
    brew services restart postgresql
    ```
    2. restart with pg_ctl
    ```
    pg_ctl -D /usr/local/var/postgres stop
    pg_ctl -D /usr/local/var/postgres start
    ```
    3. restart your Mac

    https://stackoverflow.com/questions/7975556/how-to-start-postgresql-server-on-mac-os-x

    # try 1: switch to old brew

    ```
  3. ascendbruce revised this gist May 14, 2018. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -47,6 +47,11 @@ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/aa049a47b2

    after this, the error message changed but I didn't record it down.

    ref:

    * https://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula/17757092#17757092
    * https://gist.github.com/srt32/11265183

    # try 4: build postgis from source (this works for my case)

    download source from https://postgis.net/install/
  4. ascendbruce revised this gist May 14, 2018. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -39,7 +39,15 @@ brew reinstall postgis

    ref: https://github.com/Homebrew/legacy-homebrew/issues/46358

    # try 3: build postgis from source (this works for my case)
    # try 3: install homebrew in history

    ```
    brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/aa049a47b218fda30f9a4a454119ae067a02cf50/Formula/postgis.rb
    ```

    after this, the error message changed but I didn't record it down.

    # try 4: build postgis from source (this works for my case)

    download source from https://postgis.net/install/

  5. ascendbruce created this gist May 14, 2018.
    63 changes: 63 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,63 @@
    # error message

    ```
    PG::InternalError: ERROR: incompatible library "/usr/local/lib/postgresql/postgis-2.4.so": version mismatch
    DETAIL: Server is version 9.6, library is version 10.0.
    : CREATE EXTENSION IF NOT EXISTS "postgis"
    /Users/bruce/Projects/HB-Backend/db/migrate/20151013213623_enable_postgis.rb:3:in `change'
    -e:1:in `<main>'
    Caused by:
    ActiveRecord::StatementInvalid: PG::InternalError: ERROR: incompatible library "/usr/local/lib/postgresql/postgis-2.4.so": version mismatch
    DETAIL: Server is version 9.6, library is version 10.0.
    : CREATE EXTENSION IF NOT EXISTS "postgis"
    ```

    # inspect current status

    ```
    brew info postgresql
    brew info postgis
    psql --version
    which psql
    ```

    # try 1: switch to old brew

    ```
    brew info postgis
    # if found old versions:
    brew switch postgis 2.4.4_1
    ```

    # try 2: reinstall postgis

    ```
    brew reinstall postgis
    ```

    ref: https://github.com/Homebrew/legacy-homebrew/issues/46358

    # try 3: build postgis from source (this works for my case)

    download source from https://postgis.net/install/

    in my case, it's postgis-2.4.4.tar.gz

    ```
    # change path accordingly
    brew unlink postgis
    tar zxf postgis-2.4.4.tar.gz
    cd postgis-2.4.4
    ./configure --with-pgconfig=/usr/local/Cellar/postgresql/9.6.2/bin/pg_config --with-xml2config=/usr/local/Cellar/libxml2/2.9.7/bin/xml2-config
    make
    make install
    ```

    ref:

    * https://gist.github.com/smellman/2e51b1cf449c499ad5deec454a16a7bc
    * https://github.com/Homebrew/legacy-homebrew/issues/33462