lsif-go icon indicating copy to clipboard operation
lsif-go copied to clipboard

error: failed to infer module name: unrecognized import path ""

Open hitzhangjie opened this issue 4 years ago • 6 comments

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?

hitzhangjie avatar Sep 03 '21 10:09 hitzhangjie

Got the same issue....

deepseawhale avatar Nov 09 '21 08:11 deepseawhale

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

tjdevries avatar Nov 09 '21 22:11 tjdevries

I'm seeing this for a public project/repository but not sure what's causing the issue.

violetaria avatar Apr 15 '22 19:04 violetaria

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

jessequinn avatar May 01 '22 15:05 jessequinn

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

jessequinn avatar May 01 '22 18:05 jessequinn

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).

yerden avatar Jul 10 '22 14:07 yerden