Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'invalid use of internal package' in IDE in external tests #1778

Open
scaiper opened this issue Apr 9, 2024 · 4 comments · May be fixed by #1779
Open

'invalid use of internal package' in IDE in external tests #1778

scaiper opened this issue Apr 9, 2024 · 4 comments · May be fixed by #1779

Comments

@scaiper
Copy link
Contributor

scaiper commented Apr 9, 2024

What version of gazelle are you using?

v0.36.0

What version of rules_go are you using?

v0.46.0

What version of Bazel are you using?

7.1.1

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

Linux amd64

What did you do?

Created external go test inside some internal package.
Run gazelle.
Open IDE using gopls with gopackagesdriver from rules_go.

What did you expect to see?

Code navigation should work as usual.

What did you see instead?

An "invalid use of internal package" errors in imports.

This happens due to incorrect PkgPath in gopackagesdriver output. Gazelle do not specify importpath for go_test targets, as a result gopackagesdriver in rules_go is unable to infer correct importpath.
While correct importpath is not needed to build or test go_test targets, I do not know how to fix this issue without specifying it.

Maybe relevant bazelbuild/rules_go#3845

@scaiper scaiper linked a pull request Apr 9, 2024 that will close this issue
@linzhp
Copy link
Contributor

linzhp commented Apr 14, 2024

@JamyDev Did we run into this issue? If so, how did you solve it?

@JamyDev
Copy link
Contributor

JamyDev commented Apr 16, 2024

This may still be an outstanding issue in our setup. Will have a look when I have time.

@JamyDev
Copy link
Contributor

JamyDev commented Apr 16, 2024

After a quick sanity check, it does not seem to be related to bazelbuild/rules_go#3845.

@scaiper could you somehow set up a repro repository? Our initial sanity check seemed to give proper results for the PkgPath for the ext test.

@scaiper
Copy link
Contributor Author

scaiper commented Apr 23, 2024

@JamyDev Here is the demo repository https://github.com/scaiper/pkg_path_demo
To reproduce run the echo '{"tests": true}' | bazel run @rules_go//go/tools/gopackagesdriver ./... builtin command and look at PgkPath of a_test target.

      "ID": "@@//internal/a:a_test",
      "Name": "a_test",
      "PkgPath": "internal/a/a_test",

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 a pull request may close this issue.

3 participants