error: failed to infer module name: unrecognized import path ""
Hi, I am a new user to lsif-go, I want to use code intelligence in sourcegraph instead of search-based code navigation.
So I am here and run 'lsif-go' in my git repository, but it reports an error:
error: failed to infer module name: unrecognized import path ""
When I read the code, apparently this error is caused by golang.org/x/tools/go/vcs.vcs.RepoRootForImportPath(...).
I used private git platform, and the repo's module is like git.code.xxx.com/group/repo, function vcs.RepoRootForImportPath(...) reports error: unrecognized import path "git.code.xxx.com/xxxx/yyyy".
So what should I do to work around this?
Got the same issue....
Hi! Thanks for reporting!
I will be looking into this (but I won't be in office for the next few days, so most of the investigation will come next week).
Could you tell me what the output of this command is in the repository that you're running this in?
go list -mod=readonly -m
Also, if I created a PR with some additional debugging information, would it be possible to check out the branch, build lsif-go and then run that against your project? That might make debugging it a lot easier.
Thanks!
TJ
I'm seeing this for a public project/repository but not sure what's causing the issue.
private gitlab pipeline with code_navigation is also doing it:
code_navigation:
stage: test
image: sourcegraph/lsif-go:v1
allow_failure: true # recommended
script:
- lsif-go
artifacts:
reports:
lsif: dump.lsif
error in pipeline
error: failed to infer module name: unrecognized import path "xxx.xxx.xxx.xxx/.../.../cis-filter-deployer"
Make sure your git repo has a remote (git remote add origin [email protected]:owner/repo)
go list -mod=readonly -m
cis-filter-deployer
the following appears to work on gitlab 14.10
code_navigation:
stage: test
image: sourcegraph/lsif-go:v1.2
allow_failure: true
script:
- apt-get update && apt-get -yy install libicu-dev
- lsif-go -o dump.lsif
artifacts:
reports:
lsif: dump.lsif
I can confirm the issue running in gitlab runner in a private repo.
# lsif-go -o dump.lsif
✔ Resolving module name... Done
error: failed to infer module name: unrecognized import path "xxxx.xxx.xxx/path/project"
Make sure your git repo has a remote (git remote add origin [email protected]:owner/repo)
UPD: fixed that by appending our self-signed certificate to /etc/ssl/certs/ca-certificates.crt (running Rocky Linux 8, btw).