aaif-goose/goose · error · SystemExit
could not find findLibraryName in generated Kotlin bindings
Error message
could not find findLibraryName in generated Kotlin bindings
What it means
SystemExit raised by the Python patch step in crates/goose-sdk/scripts/prepare-maven-package.sh when the generated Kotlin bindings file (goose.kt from uniffi-bindgen) does not contain the exact line 'private fun findLibraryName(componentName: String): String {'. The script injects NativeLibraryLoader.ensureLoaded() right after that line; if the generator's output format drifted, the anchor is gone and patching aborts.
Source
Thrown at crates/goose-sdk/scripts/prepare-maven-package.sh:52
cp LICENSE "$resources_dir/META-INF/LICENSE"
"$bindgen" generate \
--library "$native_lib" \
--config crates/goose-sdk/uniffi.toml \
--language kotlin \
--no-format \
--out-dir "$kotlin_dir" 2>/dev/null
python3 - "$kotlin_dir/io/github/aaif_goose/goose.kt" <<'PY'
import sys
from pathlib import Path
path = Path(sys.argv[1])
text = path.read_text()
needle = 'private fun findLibraryName(componentName: String): String {\n'
replacement = needle + ' NativeLibraryLoader.ensureLoaded()\n'
if needle not in text:
raise SystemExit('could not find findLibraryName in generated Kotlin bindings')
path.write_text(text.replace(needle, replacement, 1))
PY
cp -R "$support_kotlin_dir"/. "$kotlin_dir"/
cp "$native_lib" "$resources_dir/$resource_prefix/"
View on GitHub (pinned to 3810898a74)
Solutions
- Open $kotlin_dir/io/github/aaif_goose/goose.kt and locate the library-loading function; note its current exact signature/text
- Pin the uniffi-bindgen / uniffi crate versions to the pair that produced the expected layout
- Update the needle string in prepare-maven-page.sh's Python step to match the newly generated line
- Check that the uniffi-bindgen invocation above the patch step actually succeeded (remove 2>/dev/null to see errors) before patching
Example fix
# before (script)
needle = 'private fun findLibraryName(componentName: String): String {\n'
# after — match current generated output, e.g.
needle = 'private fun findLibraryName(componentName: String): String {\n' # keep in sync with uniffi-bindgen output; pin its version instead when possible Defensive patterns
Strategy: validation
Validate before calling
kt="$kotlin_dir/io/github/aaif_goose/goose.kt"
grep -q 'private fun findLibraryName(componentName: String): String {' "$kt" || { echo "generated bindings drifted; pin uniffi versions" >&2; exit 1; } Prevention
- Pin uniffi and uniffi-bindgen versions in Cargo/requirements
- Fail the script loudly when the anchor line is missing (already does) and treat it as a version-drift signal
- Add a CI smoke test that runs prepare-maven-package.sh on every dependency bump
When it happens
Trigger: Running prepare-maven-package.sh after a uniffi-bindgen or uniffi macro upgrade that renames findLibraryName, changes its signature/formatting, or reorders the generated code; also when the .kt file is generated into a different path and the target file is stale or empty.
Common situations: Cargo/UniFFI version bump in CI changes generated-code formatting; the out-dir layout of uniffi-bindgen changed (package path io/github/aaif_goose moved); regeneration failed upstream (exit hidden by 2>/dev/null) leaving an old or empty goose.kt.
Related errors
- rust_version must look like 0.1.0 or 0.1.0-alpha.0
- expected one match for {pattern!r} in {path}
- provider check failed
- Test replay failed for '{}' ({}): {}. File deleted - re-run
AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16).
Data as JSON: /api/errors/631180de559e28d8.
Report an issue: GitHub.