Skip to content

@@HOMEBREW_JAVA@@ is not relocated; Maven fails without JAVA_HOME #358

Description

@StayBlue

Environment

  • nanobrew: v0.1.205
  • macOS: 26.5.1
  • arch: arm64
  • Maven: 3.9.16
  • Nanobrew OpenJDK installed

Summary

The Homebrew Maven bottle uses @@HOMEBREW_JAVA@@ in its wrappers. Nanobrew's placeholder replacer does not recognize this token, leaving the installed Maven commands broken unless the caller manually supplies JAVA_HOME.

I could not find an existing issue for @@HOMEBREW_JAVA@@ or Maven. #39 fixed the standard @@HOMEBREW_CELLAR@@, @@HOMEBREW_PREFIX@@, and @@HOMEBREW_REPOSITORY@@ text placeholders but does not cover this token.

Reproduction

The installed wrappers retain the literal placeholder:

rg -n '@@HOMEBREW' /opt/nanobrew/prefix/Cellar/maven/3.9.16/bin/mvn{,Debug,yjp}
bin/mvn:2:JAVA_HOME="${JAVA_HOME:-@@HOMEBREW_JAVA@@}" exec "/opt/nanobrew/prefix/Cellar/maven/3.9.16/libexec/bin/mvn" "$@"
bin/mvnDebug:2:JAVA_HOME="${JAVA_HOME:-@@HOMEBREW_JAVA@@}" ...
bin/mvnyjp:2:JAVA_HOME="${JAVA_HOME:-@@HOMEBREW_JAVA@@}" ...

Run Maven without inheriting a caller-provided Java environment:

env -i HOME="$HOME" \
  PATH=/opt/nanobrew/prefix/bin:/usr/bin:/bin \
  LC_ALL=C \
  /opt/nanobrew/prefix/Cellar/maven/3.9.16/bin/mvn -version

Result:

The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.

Exit status: 1.

Relevant implementation

src/platform/placeholder.zig currently replaces only the prefix, cellar, repository, library, and Perl placeholders. There is no PLACEHOLDER_JAVA or handling for @@HOMEBREW_JAVA@@.

Expected

Nanobrew should replace @@HOMEBREW_JAVA@@ with the appropriate Java home from the resolved formula dependency, so Maven works without a user-supplied JAVA_HOME.

The placeholder scan/doctor checks should also flag unknown @@HOMEBREW_*@@ tokens that remain in executable wrappers after installation.

Refs #39 and #347.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions