sourcegraph / src-cli

Sourcegraph CLI
https://sourcegraph.com
Apache License 2.0
276 stars 60 forks source link

Failed to upload index file #558

Open KashingLiu opened 3 years ago

KashingLiu commented 3 years ago

πŸ’‘ Inferred arguments repo: commit: root: file: dump.lsif indexer: lsif-clang

βœ… Index compressed πŸ’‘ Indexed compressed (1.23MB -> 0.19MB). ❌ Failed to upload index file

Strum355 commented 3 years ago

Hi KashingLiu. What output do you get when you run with -trace 3 flag set? πŸ™‚

KashingLiu commented 3 years ago

Hi KashingLiu. What output do you get when you run with -trace 3 flag set? πŸ™‚

@Strum355 here is my output, when I put the url which shows unknown repository into chrome, it can redirect to my correct repository, and I use ssh to clone my repository. Should I set something before I upload the lsif file? I don't know what is behind my IP and my port ".api/lsif/upload....." mean. Or can I just put the lsif file into somewhere in the sourcegraph docker?

POST http://****myIP****:7080/.api/lsif/upload?commit=f73bb8a29fc9ebf8ea0699ff90ef86bcd913522e&indexerName=lsif-clang&repository=****my repo url/%2Fmy repo****%2Ftesttt

Request Headers: Authorization: [token cc0023280f3d6c8b55229a1f5f8f6ffa577173db] Content-Type: [application/x-ndjson+lsif]

< POST http://****myIP****:7080/.api/lsif/upload?commit=f73bb8a29fc9ebf8ea0699ff90ef86bcd913522e&indexerName=lsif-clang&repository=****my repo url%2Fmy repo%2Ftesttt 404 Not Found in 13.998028ms < Response Headers: < Cache-Control: [no-cache, max-age=0] < Connection: [keep-alive] < Content-Length: [63] < Content-Type: [text/plain; charset=utf-8] < Date: [Sat, 26 Jun 2021 02:59:51 GMT] < Server: [nginx] < Vary: [Accept-Encoding Authorization Cookie, Authorization, X-Requested-With] < X-Content-Type-Options: [nosniff] < X-Frame-Options: [DENY] < X-Trace: [#tracer-not-enabled] < X-Xss-Protection: [1; mode=block] < Response Body: unknown repository "my repo url/path to my repo*****/testtt"

KashingLiu commented 3 years ago

@Strum355 Hello, it shows "< Response Body: unknown repository *my-repo-url*/*path-to-my-repo*/testtt ". Does it mean it doesn't recognize my repo url ? in the sourcegraph which I deploy on my host, I use SSH to clone the repo, and the port is 2222, so the url in the sourcegraph is repo:^***my-repo-url***-2222/*path-to-my-repo*/testtt$ , so if the repository is known, does it cause by the port? The url doesn't match because of the port? I don't know the match rule, when I upload, the POST request contains a parameter which is repository, it should be the same as what? It should be the same as my real git host url(*my-repo-url*/*path-to-my-repo*/testtt), OR the url which I get after I set the sourcegraph(***my-repo-url***-2222/*path-to-my-repo*/testtt)?

KashingLiu commented 3 years ago

@Strum355 Hello, I try to use https to clone my project and it works! But after I upload my lsif file, the code intelligence function still does not work. There is not a "Go to Defination" or something you mentioned in the documentation. What should I set or am I lost something? image Do you have a demo lsif file and a demo project to let me know how lsif work? I see some directorys and files and some arguments in the compile_commands.json, and I see some id, type, label, outV, inVs in the dump.lsif file,

Strum355 commented 3 years ago

Hi @KashingLiu. Can you confirm that there is an upload visible under site-admin/code-intelligence/uploads? There should be a list of >0 LSIF uploads listed there, and if you click on one, you should be able to see a page that looks similar to the following image (assuming you are self-hosting Sourcegraph):

Details ![image](https://user-images.githubusercontent.com/18282288/124491870-a5753480-ddab-11eb-85fd-7739a8c50048.png)

Please do note, lsif-clang is not 100% complete. There are cases where precise code intelligence may be missing (notably for macros), but I would expect there to possibly be search-based code intelligence if that is the case. As an example, heres a precise result from lsif-clang compared to a symbol that only gives search based results, within the same repo.

KashingLiu commented 3 years ago

Hello @Strum355 . I have another question. Does the search-based or precise code intelligence base on an extension? I can upload my lsif data successfully, but there is not a pop-up shows "Go to defination". My sourcegraph docker uses proxy to connect the Internet, and it can’t visit the extension url. "Unable to contact extension registry: Get "https://sourcegraph.com/.api/registry/extensions": dial tcp 104.18.3.36:443: i/o timeout". So I think that the problem causes by the unreachable extensions.

Strum355 commented 3 years ago

Hi @KashingLiu, yes the extensions are required for code intelligence. If youre unable to connect to sourcegraph.com/.api/registry/extension, you may be able to run a private extension registry and copy the relevant extensions from the sourcegraph.com registry to it. The docs for that can be found here https://docs.sourcegraph.com/admin/extensions