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

golang.org/x/sys and other packages don't seem to work #18

Closed
floren opened this issue Apr 23, 2020 · 15 comments
Closed

golang.org/x/sys and other packages don't seem to work #18

floren opened this issue Apr 23, 2020 · 15 comments

Comments

@floren
Copy link

floren commented Apr 23, 2020

I'm walking through the dependencies in my go.mod and I find that the golang.org/x/ repositories give me trouble:

% go-licenses csv golang.org/x/sys
Error: errors for ["golang.org/x/sys"]:
golang.org/x/sys: -: module golang.org/x/sys@latest found (v0.0.0-20200420163511-1957bb5e6d1f), but does not contain package golang.org/x/sys
Usage:
  licenses csv <package> [flags]

Flags:
      --git_remote stringArray   Remote Git repositories to try (default [origin,upstream])
  -h, --help                     help for csv

Global Flags:
      --alsologtostderr                  log to standard error as well as files
      --confidence_threshold float       Minimum confidence required in order to positively identify a license. (default 0.9)
      --log_backtrace_at traceLocation   when logging hits line file:N, emit a stack trace (default :0)
      --log_dir string                   If non-empty, write log files in this directory
      --logtostderr                      log to standard error instead of files
      --stderrthreshold severity         logs at or above this threshold go to stderr (default 2)
  -v, --v Level                          log level for V logs
      --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging

F0423 16:43:51.988116     851 main.go:43] errors for ["golang.org/x/sys"]:
golang.org/x/sys: -: module golang.org/x/sys@latest found (v0.0.0-20200420163511-1957bb5e6d1f), but does not contain package golang.org/x/sys

Is there a trick to this? Advice?

@RJPercival
Copy link
Contributor

Can you provide a copy of your go.mod file please?

@spatecon
Copy link

The same with:

github.com/oklog/oklog
google.golang.org/genproto
golang.org/x/crypto

and others.

@RJPercival
Copy link
Contributor

@ilya310300 @floren Please provide a copy of your go.mod file or link to a repo.

@sebd71
Copy link

sebd71 commented Jun 1, 2020

I'm not fully sure that it's the right way to fix that but adding "golang.org": "blob/master/", in repoPathPrefixes definition (file library.go) seems fix the problem :

var (
	// TODO(RJPercival): Support replacing "master" with Go Module version
	repoPathPrefixes = map[string]string{
		"github.com":    "blob/master/",
		"bitbucket.org": "src/master/",
		"golang.org":    "blob/master/",
	}
)

@RJPercival : would you please confirm if it's right way to fix that issue ?

@floren
Copy link
Author

floren commented Jun 1, 2020

If you drop the contents of this gist into a directory, you can 'go build' and it'll work, but running go-licenses csv golang.org/x/sys will fail as mentioned above.

https://gist.github.com/floren/70c8f5c9c12c4b6a2e4b73416604e34d

@kstenerud
Copy link

kstenerud commented Jun 15, 2020

This is a general problem with the sys package. For example. the following fails: https://play.golang.org/p/saGt7CYOsm4

package main

import (
	"golang.org/x/sys"
)

func main() {
}
go: finding module for package golang.org/x/sys
go: downloading golang.org/x/sys v0.0.0-20200610111108-226ff32320da
prog.go:4:2: module golang.org/x/sys@latest found (v0.0.0-20200610111108-226ff32320da), but does not contain package golang.org/x/sys

@dcormier
Copy link

dcormier commented Nov 24, 2020

Here is a repo showing this problem: https://github.com/dcormier/go-licenses (complete with the requested go.mod file)

Here is the result of running the command in that repo:

> go-licenses csv ./...
E1124 13:39:33.985051    5489 library.go:108] Failed to find license for github.com/dcormier/go-licenses: no file/directory matching regexp "^(?i)(LICEN(S|C)E|COPYING|README|NOTICE)(\\..+)?$" found for /Users/daniel/dev/go-licenses
E1124 13:39:35.655555    5489 csv.go:84] Error discovering URL for "/Users/daniel/go/pkg/mod/go.uber.org/atomic@v1.7.0/LICENSE.txt":
- cannot determine URL for "go.uber.org/atomic" package
E1124 13:39:35.660957    5489 csv.go:84] Error discovering URL for "/Users/daniel/go/pkg/mod/contrib.go.opencensus.io/exporter/aws@v0.0.0-20200617204711-c478e41e60e9/LICENSE":
- unsupported package host "contrib.go.opencensus.io" for "contrib.go.opencensus.io/exporter/aws"
E1124 13:39:35.698183    5489 csv.go:84] Error discovering URL for "/Users/daniel/go/pkg/mod/go.opencensus.io@v0.22.5/LICENSE":
- cannot determine URL for "go.opencensus.io" package
E1124 13:39:35.766210    5489 csv.go:84] Error discovering URL for "/Users/daniel/go/pkg/mod/go.uber.org/fx@v1.13.1/LICENSE":
- cannot determine URL for "go.uber.org/fx" package
E1124 13:39:35.770829    5489 csv.go:84] Error discovering URL for "/Users/daniel/go/pkg/mod/go.uber.org/multierr@v1.6.0/LICENSE.txt":
- cannot determine URL for "go.uber.org/multierr" package
E1124 13:39:35.778800    5489 csv.go:84] Error discovering URL for "/Users/daniel/go/pkg/mod/golang.org/x/text@v0.3.4/LICENSE":
- unsupported package host "golang.org" for "golang.org/x/text"
E1124 13:39:35.827558    5489 csv.go:84] Error discovering URL for "/Users/daniel/go/pkg/mod/go.uber.org/dig@v1.10.0/LICENSE":
- cannot determine URL for "go.uber.org/dig" package
E1124 13:39:35.834144    5489 csv.go:84] Error discovering URL for "/Users/daniel/go/pkg/mod/golang.org/x/net@v0.0.0-20201110031124-69a78807bb2b/LICENSE":
- unsupported package host "golang.org" for "golang.org/x/net/idna"
go.uber.org/atomic,Unknown,MIT
github.com/dcormier/go-licenses,Unknown,Unknown
contrib.go.opencensus.io/exporter/aws,Unknown,Apache-2.0
github.com/jmespath/go-jmespath,https://github.com/jmespath/go-jmespath/blob/master/LICENSE,Apache-2.0
go.opencensus.io,Unknown,Apache-2.0
github.com/golang/groupcache/lru,https://github.com/golang/groupcache/blob/master/lru/LICENSE,Apache-2.0
go.uber.org/fx,Unknown,MIT
go.uber.org/multierr,Unknown,MIT
golang.org/x/text,Unknown,BSD-3-Clause
github.com/aws/aws-sdk-go,https://github.com/aws/aws-sdk-go/blob/master/LICENSE.txt,Apache-2.0
github.com/aws/aws-sdk-go/internal/sync/singleflight,https://github.com/aws/aws-sdk-go/blob/master/internal/sync/singleflight/LICENSE,BSD-3-Clause
go.uber.org/dig,Unknown,MIT
golang.org/x/net/idna,Unknown,BSD-3-Clause
> 

@chrisjd20
Copy link

Im not sure if this is the same problem but

import (
	"golang.org/x/sys/windows/registry"
)
PS D:\Unity_Projects\nwt7-lvl5-castles\windows\services\go_http_web_service> go build .\http.go
http.go:24:2: no required module provides package golang.org/x/sys/windows/registry: go.mod file not found in current directory or any parent directory; see 'go help modules'

@Bobgy
Copy link
Collaborator

Bobgy commented Jul 31, 2021

I think the root cause is that golang.org/x/sys is a module, but it is not a package.
Refer to its source code: https://cs.opensource.google/go/x/sys.
There are no go source files directly in this folder.

So we cannot load the package golang.org/x/sys.

@Bobgy
Copy link
Collaborator

Bobgy commented Jul 31, 2021

This can be workarounded by my v2 implementation: #71 that works on modules directly instead of packages.

@Bobgy
Copy link
Collaborator

Bobgy commented Apr 11, 2022

Please comment if this still persists, updated documentation and released go modules support in v1.1.0.

Note, go-licenses csv accepts a go package, a folder without go files is not a go package.

@Bobgy Bobgy closed this as completed Apr 11, 2022
@gennaro-tedesco
Copy link

I am still seeing the problem:

no Go files in ~/go/src/golang.org/x/sys

what was the accepted solution/workaround? I see that #82 was merged though: is anyone else still experiencing the problem?

@Bobgy
Copy link
Collaborator

Bobgy commented Nov 3, 2022

@gennaro-tedesco can you share detailed reproduction steps?

@gennaro-tedesco
Copy link

Sure: I am on macOS 10.16.0 Big Sur and I have tried with different values for the GO111MODULE env variable.

  • if installing via go install golang.org/x/sys@latest I get a combination of "no Go files in ~/go/src/golang.org/x/sys" and "module golang.org/x/sys@latest found (v0.1.0), but does not contain package golang.org/x/sys" according to whether or not I set GO111MODULE to explicit values.

  • if importing golang.org/x/sys in a module and running go mod tidy I get

../../go/pkg/mod/golang.org/x/sys@v0.0.0-20200918174421-af09f7315aff/unix/zsyscall_darwin_arm64.1_13.go:40:3: //go:linkname must refer to declared function or variable

@Bobgy
Copy link
Collaborator

Bobgy commented Nov 3, 2022

Sure: I am on macOS 10.16.0 Big Sur and I have tried with different values for the GO111MODULE env variable.

  • if installing via go install golang.org/x/sys@latest I get a combination of "no Go files in ~/go/src/golang.org/x/sys" and "module golang.org/x/sys@latest found (v0.1.0), but does not contain package golang.org/x/sys" according to whether or not I set GO111MODULE to explicit values.

  • if importing golang.org/x/sys in a module and running go mod tidy I get

../../go/pkg/mod/golang.org/x/sys@v0.0.0-20200918174421-af09f7315aff/unix/zsyscall_darwin_arm64.1_13.go:40:3: /go:linkname must refer to declared function or variable

The commands you ran do not relate to go licenses though.

Note golang.org/x/sys is not a go package, that's why those commands failed. There are go packages with golang.org/x/sys as prefix.

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

No branches or pull requests

9 participants