go-pmtiles icon indicating copy to clipboard operation
go-pmtiles copied to clipboard

CLI command `pmtiles version` blank when installed using homebrew

Open mizmay opened this issue 10 months ago • 4 comments

When I run pmtiles version to see what build of the CLI I am running I always get pmtiles dev, commit none, built at unknown.

It's an issue only because I'm using the CLI infrequently so am always inclined to check whether I have a recent enough version when I go to try something.

Steps to reproduce:

  1. Download current / latest release for my m1 2020 Macbook Air go-pmtiles-1.23.1_Darwin_arm64.zip

  2. Open to install

Last login: Fri Jan 10 12:25:24 on ttys009
/Users/mizmay/Downloads/pmtiles ; exit;
mizmay@Stephanies-Personal ~ % /Users/mizmay/Downloads/pmtiles ; exit;
Usage: pmtiles <command>

Flags:
  -h, --help    Show context-sensitive help.

Commands:
  convert <input> <output>
    Convert an MBTiles or older spec version to PMTiles.

  show <path>
    Inspect a local or remote archive.

  tile <path> <z> <x> <y>
    Fetch one tile from a local or remote archive and output on stdout.

  extract <input> <output>
    Create an archive from a larger archive for a subset of zoom levels or
    geographic region.

  verify <input>
    Verify the correctness of an archive structure, without verifying individual
    tile contents.

  serve <path>
    Run an HTTP proxy server for Z/X/Y tiles.

  upload --bucket=STRING <input-pmtiles> <remote-pmtiles>
    Upload a local archive to remote storage.

  version
    Show the program version.

Run "pmtiles <command> --help" for more information on a command.

Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]
  1. Check version
mizmay@Stephanies-Personal ~ % pmtiles version --help
Usage: pmtiles version

Show the program version.

Flags:
  -h, --help    Show context-sensitive help.
mizmay@Stephanies-Personal ~ % pmtiles version       
pmtiles dev, commit none, built at unknown

Other things I tried

I tried brew install pmtiles and got the same result.

mizmay avatar Jan 10 '25 20:01 mizmay

This is what the output of pmtiles 1.23.1 looks like for me:

pmtiles version
pmtiles 1.23.1, commit cb7d438ef3ce0c58066286727c5e8844f46628dc, built at 2025-01-06T06:31:36Z

Can you type which pmtiles? Is it pointing to an executable in your Homebrew directory? You should either remove the Homebrew one if you're going to use the binary from https://github.com/protomaps/go-pmtiles/releases/tag/v1.23.1 or put the binary earlier on your path.

The Homebrew install is probably building the project from source (I don't maintain it) and does not include the release information. The releases for Mac are signed with my paid developer key so it doesn't require bypassing the security warning on MacOS.

bdon avatar Jan 11 '25 04:01 bdon

You are right it was the Homebrew version plus some weirdness with the path. When I uninstalled that plus moved the executable from /usr/local/bin to /opt/local/bin, pmtiles version works.

mizmay@Stephanies-Personal bin % pmtiles version
pmtiles 1.23.1, commit cb7d438ef3ce0c58066286727c5e8844f46628dc, built at 2025-01-06T06:31:36Z

Feel free to close (or leave open). Thanks!

mizmay avatar Jan 12 '25 01:01 mizmay

This line in the Homebrew formula: https://github.com/Homebrew/homebrew-core/blob/be72125f81db1b4daab71bb824ddf28c8c91811c/Formula/p/pmtiles.rb#L25

needs to pass this additional ldflag to populate the version information:

go build -ldflags="-X 'main.version=1.23.1'" main.go

bdon avatar Jan 12 '25 05:01 bdon

pmtiles version also shows pmtiles dev, commit none, built at unknown when building locally, as well as Homebrew.

Leaving this for others doing local development.


# macOS
go build -ldflags="-X 'main.version=1.23.1-dev' -X 'main.commit=beefdea' -X 'main.date=`date`'"

./go-pmtiles version
# Result
# pmtiles 1.23.1-dev, commit beefdea, built at Mon Apr 28 17:14:45 PDT 2025

roblabs avatar Apr 29 '25 00:04 roblabs