Skip to content

Conversation

@sloretz
Copy link
Contributor

@sloretz sloretz commented Sep 26, 2025

This changes option go_package to use absolute import paths instead of relative ones. This fixes two build issues when using this library with Bazel via bazel_gazelle.

Example build errors fixed by this change:

ERROR: /home/sloretz/projects/bg_bug/streaming_service/BUILD:13:17: GoCompilePkg streaming_service/streaming_service_go_proto.a failed: (Exit 1): builder failed: error executing GoCompilePkg command (from target //streaming_service:streaming_service_go_proto) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_go++go_sdk+main___download_0/builder_reset/builder compilepkg -sdk external/rules_go++go_sdk+main___download_0 -goroot ... (remaining 67 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
bazel-out/k8-fastbuild/bin/streaming_service/streaming_service_go_proto_/bg_bug/streaming_service/streaming_service_go_proto/streaming_service.pb.go:10:4: could not import ./openapiv3 (open : no such file or directory)
compilepkg: error running subcommand external/rules_go++go_sdk+main___download_0/pkg/tool/linux_amd64/compile: exit status 2
ERROR: /home/sloretz/.cache/bazel/_bazel_sloretz/7f1c610792df1dcd4df92ba962d4dced/external/gazelle++go_deps+com_github_google_gnostic_models/extensions/BUILD.bazel:19:11: GoCompilePkg external/gazelle++go_deps+com_github_google_gnostic_models/extensions/extensions.a [for tool] failed: (Exit 1): builder failed: error executing GoCompilePkg command (from target @@gazelle++go_deps+com_github_google_gnostic_models//extensions:extensions) bazel-out/k8-opt-exec-ST-1be4dcb80a27/bin/external/rules_go++go_sdk+main___download_0/builder_reset/builder compilepkg -sdk external/rules_go++go_sdk+main___download_0 -goroot ... (remaining 29 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/gazelle++go_deps+com_github_google_gnostic_models/extensions/extensions.go:40:14: undefined: ExtensionHandlerRequest
external/gazelle++go_deps+com_github_google_gnostic_models/extensions/extensions.go:49:15: undefined: ExtensionHandlerResponse
compilepkg: error running subcommand external/rules_go++go_sdk+main___download_0/pkg/tool/linux_amd64/compile: exit status 2
Use --verbose_failures to see the command lines of failed build steps.

I don't know enough about golang to be able to explain why this fixes the issue 🤷

This changes `option go_package` to use absolute import paths instead of
relative ones. This fixes two seemingly unrelated issues when using this
library with Bazel via bazel_gazelle.

Example compile errors fixed by this change:

```
ERROR: /home/sloretz/projects/bg_bug/streaming_service/BUILD:13:17: GoCompilePkg streaming_service/streaming_service_go_proto.a failed: (Exit 1): builder failed: error executing GoCompilePkg command (from target //streaming_service:streaming_service_go_proto) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_go++go_sdk+main___download_0/builder_reset/builder compilepkg -sdk external/rules_go++go_sdk+main___download_0 -goroot ... (remaining 67 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
bazel-out/k8-fastbuild/bin/streaming_service/streaming_service_go_proto_/bg_bug/streaming_service/streaming_service_go_proto/streaming_service.pb.go:10:4: could not import ./openapiv3 (open : no such file or directory)
compilepkg: error running subcommand external/rules_go++go_sdk+main___download_0/pkg/tool/linux_amd64/compile: exit status 2
```

```
ERROR: /home/sloretz/.cache/bazel/_bazel_sloretz/7f1c610792df1dcd4df92ba962d4dced/external/gazelle++go_deps+com_github_google_gnostic_models/extensions/BUILD.bazel:19:11: GoCompilePkg external/gazelle++go_deps+com_github_google_gnostic_models/extensions/extensions.a [for tool] failed: (Exit 1): builder failed: error executing GoCompilePkg command (from target @@gazelle++go_deps+com_github_google_gnostic_models//extensions:extensions) bazel-out/k8-opt-exec-ST-1be4dcb80a27/bin/external/rules_go++go_sdk+main___download_0/builder_reset/builder compilepkg -sdk external/rules_go++go_sdk+main___download_0 -goroot ... (remaining 29 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/gazelle++go_deps+com_github_google_gnostic_models/extensions/extensions.go:40:14: undefined: ExtensionHandlerRequest
external/gazelle++go_deps+com_github_google_gnostic_models/extensions/extensions.go:49:15: undefined: ExtensionHandlerResponse
compilepkg: error running subcommand external/rules_go++go_sdk+main___download_0/pkg/tool/linux_amd64/compile: exit status 2
Use --verbose_failures to see the command lines of failed build steps.
```

Signed-off-by: Shane Loretz <sloretz@intrinsic.ai>
Copy link
Collaborator

@Jefftree Jefftree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This follows best practices of using absolute paths

@Jefftree Jefftree merged commit 289d7b4 into google:main Nov 19, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants