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

"use of internal package not allowed" error #64005

Closed
wulianglongrd opened this issue Nov 8, 2023 · 9 comments
Closed

"use of internal package not allowed" error #64005

wulianglongrd opened this issue Nov 8, 2023 · 9 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@wulianglongrd
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
go version go1.21.3 darwin/amd64
and
built from the source code master branch

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE='auto'
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/logx/Library/Caches/go-build'
GOENV='/Users/logx/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/logx/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/logx/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.21.3'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD=''
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/mj/fy4gncls07x2y19k7sj9l0tr0000ks/T/go-build4253779863=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I'm analyzing the source code, and running its test cases, but getting the "use of internal package ... not allowed" error. Here are the steps to reproduce:

step 1: clone the source code

$ cd ~
$ mkdir devgo && cd devgo
$ git clone https://go.googlesource.com/go

step 2: make.bash

$ cd go/src
$ ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.21.3 darwin/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/amd64.
---
Installed Go for darwin/amd64 in /Users/logx/devgo/go
Installed commands in /Users/logx/devgo/go/bin
*** You need to add /Users/logx/devgo/go/bin to your PATH.

So far, everything is fine.

step 3: run test case

$ pwd
/Users/logx/devgo/go/src/crypto/sha1
$ /Users/logx/devgo/go/bin/go test .
package std/crypto/sha1
	sha1.go:13:2: use of internal package crypto/internal/boring not allowed

I followed this documentation, but when running the test case, I got the above error.

What did you expect to see?

The test case runs successfully without any errors. Because I didn't make any changes.

What did you see instead?

Got the error mentioned above.

@thanm thanm added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 8, 2023
@thanm
Copy link
Contributor

thanm commented Nov 8, 2023

From your go env digest it looks as though your GOROOT is still set up to point to /usr/local/go and not
/Users/logx/devgo/go.

Try:

$ cd /Users/logx/devgo/go/src/crypto/sha1
$ export PATH="/Users/logx/devgo/go/bin:${PATH}"
$ go test .

and see if that helps.

@randall77
Copy link
Contributor

Strange. I cannot reproduce.

Try unsetting GO111MODULE and GOTOOLCHAIN environment variables. Those are the only ones in your list that aren't in mine. (I tried setting mine to your values, but that didn't reproduce for me.)

Could there be an old distribution at your checkout location? Add rm -fr devgo to your instruction list.

@wulianglongrd
Copy link
Contributor Author

@thanm thanks, The following is the running result

$ cd /Users/logx/devgo/go/src/crypto/sha1
$ export PATH="/Users/logx/devgo/go/bin:${PATH}"
$ go test .
package std/crypto/sha1
	sha1.go:13:2: use of internal package crypto/internal/boring not allowed

$ go env | grep GOPATH
GOPATH='/Users/logx/go'

$ GOPATH=/Users/logx/devgo/go
$ go env | grep GOPATH
GOPATH='/Users/logx/devgo/go'

$ go test .
package std/crypto/sha1
	sha1.go:13:2: use of internal package crypto/internal/boring not allowed

@wulianglongrd
Copy link
Contributor Author

@randall77 I deleted multiple times today with the same result. At the same time, I deleted the cache via go clean -cache, same thing.

@wulianglongrd
Copy link
Contributor Author

wulianglongrd commented Nov 8, 2023

Some more information, if I execute all.bash, I get ALL TESTS PASSED, but if I execute make.bash first, and then run.bash I get go: no such tool "dist"(printed twice).

$ ./make.bash
$ ./run.bash
go: no such tool "dist"
go: no such tool "dist"

@thanm
Copy link
Contributor

thanm commented Nov 8, 2023

Still seems like it is a path problem to me. I can reproduce the same error by running this script:

#!/bin/sh
set -x
set -e
cd /tmp
# Pick up some other bootstrap-capable go, doesn't matter which one.
export PATH="/ssd2/go1.20/bin:${PATH}"
which go
rm -rf mygo
git clone https://go.googlesource.com/go mygo 1> clonerr.txt 2>&1
cd mygo/src
bash make.bash
cd crypto/sha1
set +e
go test .
export PATH="/tmp/mygo/bin:${PATH}"
go test .

Here's my output:

+ set -e
+ cd /tmp
+ export PATH=/ssd2/go1.20/bin:/usr/local/sbin:...
+ PATH=/ssd2/go1.20/bin:...
+ which go
/ssd2/go1.20/bin/go
+ rm -rf mygo
+ git clone https://go.googlesource.com/go mygo
+ cd mygo/src
+ bash make.bash
Building Go cmd/dist using /ssd2/go1.20. (go1.20.8 linux/amd64)X:fieldtrack,boringcrypto linux/amd64)
Building Go toolchain1 using /ssd2/go1.20.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for linux/amd64.
---
Installed Go for linux/amd64 in /tmp/mygo
Installed commands in /tmp/mygo/bin
*** You need to add /tmp/mygo/bin to your PATH.
+ cd crypto/sha1
+ set +e
+ go test .
package std/crypto/sha1
	sha1.go:13:2: use of internal package crypto/internal/boring not allowed
package std/crypto/sha1
	sha1block_amd64.go:7:8: use of internal package internal/cpu not allowed
+ export PATH=/tmp/mygo/bin:/ssd2/go1.20/bin:...
+ PATH=/tmp/mygo/bin:/ssd2/go1.20/bin:...
+ go test .
ok  	crypto/sha1	0.031s

What happens when you run this script on your system (commenting out the first 'export PATH=')?

@wulianglongrd
Copy link
Contributor Author

+ set -e
+ cd /tmp
+ export PATH=/usr/local/go/bin:/Users/logx/.sdkman/candidates/gradle/current/bin:/Users/logx/.rpc-tools:/Users/logx/go/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/logx/.cargo/bin:/Applications/Wireshark.app/Contents/MacOS:/usr/local/tinygo/bin:/Users/logx/istio/istio-1.19.1/bin:/Applications/CMake.app/Contents/bin:/Users/logx/logx.d/bin:/usr/local/maven/bin:/usr/local/gradle/bin
+ PATH=/usr/local/go/bin:/Users/logx/.sdkman/candidates/gradle/current/bin:/Users/logx/.rpc-tools:/Users/logx/go/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/logx/.cargo/bin:/Applications/Wireshark.app/Contents/MacOS:/usr/local/tinygo/bin:/Users/logx/istio/istio-1.19.1/bin:/Applications/CMake.app/Contents/bin:/Users/logx/logx.d/bin:/usr/local/maven/bin:/usr/local/gradle/bin
+ which go
/usr/local/go/bin/go
+ rm -rf mygo
+ git clone https://go.googlesource.com/go mygo
+ cd mygo/src
+ bash make.bash
Building Go cmd/dist using /usr/local/go. (go1.21.3 darwin/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/amd64.
---
Installed Go for darwin/amd64 in /tmp/mygo
Installed commands in /tmp/mygo/bin
*** You need to add /tmp/mygo/bin to your PATH.
+ cd crypto/sha1
+ set +e
+ go test .
go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available
+ export PATH=/tmp/mygo/bin:/usr/local/go/bin:/Users/logx/.sdkman/candidates/gradle/current/bin:/Users/logx/.rpc-tools:/Users/logx/go/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/logx/.cargo/bin:/Applications/Wireshark.app/Contents/MacOS:/usr/local/tinygo/bin:/Users/logx/istio/istio-1.19.1/bin:/Applications/CMake.app/Contents/bin:/Users/logx/logx.d/bin:/usr/local/maven/bin:/usr/local/gradle/bin
+ PATH=/tmp/mygo/bin:/usr/local/go/bin:/Users/logx/.sdkman/candidates/gradle/current/bin:/Users/logx/.rpc-tools:/Users/logx/go/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/logx/.cargo/bin:/Applications/Wireshark.app/Contents/MacOS:/usr/local/tinygo/bin:/Users/logx/istio/istio-1.19.1/bin:/Applications/CMake.app/Contents/bin:/Users/logx/logx.d/bin:/usr/local/maven/bin:/usr/local/gradle/bin
+ go test .
package std/crypto/sha1
	sha1.go:13:2: use of internal package crypto/internal/boring not allowed

@seankhliao
Copy link
Member

what's in /Users/logx/Library/Application Support/go/env
and what's the output of go env using the go you've built?

@wulianglongrd
Copy link
Contributor Author

Thank you everyone. Although I'm still not sure what caused the above problem, I solved it through the following solutions:

  1. Uninstall the currently installed go
$ rm -rf /usr/local/go
$ rm -rf /etc/paths.d/go

# it was cloned so long ago that I almost forgot about it.
$ rm -rf /Users/logx/go/src/google.golang.org
$ rm -rf /Users/logx/go/src/golang.org

Delete GOPATH, GOROOT config.

  1. Reinstall go

  2. Re-test according to the above steps

@golang golang locked and limited conversation to collaborators Nov 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants