Skip to content

stellar version outputs empty brackets when git revision is unavailable #2312

@leighmcculloch

Description

@leighmcculloch

What version are you using?

stellar 23.2.1 ()
stellar-xdr 23.0.0 (e83a6337204ecfdb0ac0d44ffb857130c1249b1b)
xdr curr (4b7a2ef7931ab2ca2499be68d849f38190b443ca)

What did you do?

Run stellar version

What did you expect to see?

Either:

  1. A git revision hash in the brackets: stellar 23.2.1 (abc123...)
  2. Or the package manager name if installed that way: stellar 23.2.1 (Homebrew)
  3. Or if unavailable, no brackets at all: stellar 23.2.1

What did you see instead?

Empty brackets: stellar 23.2.1 ()

Details

This affects the Homebrew release only, not cargo install releases.

The version output is generated in cmd/soroban-cli/src/commands/version.rs:43:

format!("{} ({})", pkg(), git()),

Where git() returns env!("GIT_REVISION") set by crate_git_revision::init() in the build script.

When the git revision isn't available (e.g., installed via Homebrew), the GIT_REVISION is empty, resulting in empty brackets.

Suggested fix

Check if the git revision is empty and conditionally include the package manager name or omit the brackets:

let git_rev = git();
if git_rev.is_empty() {
    // Option 1: Show package manager name (preferred)
    format!("{} (Homebrew)", pkg())
    // Option 2: Omit brackets entirely
    // format!("{}", pkg())
} else {
    format!("{} ({})", pkg(), git_rev)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions