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

C/C++ dependencies cannot be downloaded (PROXY) #3335

Closed
FerhatAkgun opened this issue Mar 21, 2019 · 43 comments
Closed

C/C++ dependencies cannot be downloaded (PROXY) #3335

FerhatAkgun opened this issue Mar 21, 2019 · 43 comments
Labels
bug help wanted Can be fixed in the public (open source) repo. Language Service
Milestone

Comments

@FerhatAkgun
Copy link

Type: General
Input information below

Please review existing issues and our documentation at https://github.com/Microsoft/vscode-cpptools/tree/master/Documentation prior to filing an issue.

Describe the bug

  • OS and Version: Windows 10

  • VS Code Version:
    Version: 1.32.3 (user setup)
    Commit: a3db5be9b5c6ba46bb7555ec5d60178ecc2eaae4
    Date: 2019-03-14T23:43:35.476Z
    Electron: 3.1.6
    Chrome: 66.0.3359.181
    Node.js: 10.2.0
    V8: 6.6.346.32
    OS: Windows_NT x64 10.0.14393

  • C/C++ Extension Version: 0.22.0

  • Other extensions you installed (and if the issue persists after disabling them):
    Bookmarks, C/C++ Snippets, C++ Intellisense, Code Runner, SVN,

I am able to access the internet right after typing my proxy credentials. Vscode is able to download the new C/C++ extension. Right after that it asks me to reload.
Right after reloading it tries to get some dependencies, which cannot be downloaded. See below:

Updating C/C++ dependencies...

Downloading package 'C/C++ language components (Windows)' Failed. Retrying... Failed. Retrying... Failed. Retrying...Waiting 8 seconds... Failed. Retrying...Waiting 16 seconds... Failed. Retrying... Done!
Downloading package 'ClangFormat (Windows)' Failed. Retrying... Failed. Retrying... Failed. Retrying...Waiting 8 seconds... Failed. Retrying...Waiting 16 seconds... Failed. Retrying... Done!
Downloading package 'Visual Studio Windows Debugger' Failed. Retrying... Failed. Retrying... Failed. Retrying...Waiting 8 seconds... Failed. Retrying...Waiting 16 seconds... Failed. Retrying... Done!

Installing package 'C/C++ language components (Windows)'
Failed at stage: installPackages
Error: end of central directory record signature not found

If you work in an offline environment or repeatedly see this error, try downloading a version of the extension with all the dependencies pre-included from https://github.com/Microsoft/vscode-cpptools/releases, then use the "Install from VSIX" command in VS Code to install it.

@bobbrow
Copy link
Member

bobbrow commented Mar 26, 2019

The VS Code Marketplace hosts our extension VSIX in a location different from where the dependencies are downloaded. There could be a proxy configuration issue here. If you are able to help us out, I can show you what code needs to be debugged (here) and perhaps we can discover what the proxy issue is. Otherwise, you can download an all-inclusive VSIX package from the link above (https://github.com/Microsoft/vscode-cpptools/releases)

@bobbrow bobbrow added bug Language Service help wanted Can be fixed in the public (open source) repo. labels Mar 26, 2019
@rrysolutions
Copy link

I have tried installing the recommended VSIX, but I still get the download errors every time I launch Code.

@sean-mcmanus
Copy link
Collaborator

I'm not able to repro the bug. I successfully download https://github.com/Microsoft/vscode-cpptools/releases/download/0.22.1/cpptools-win32.vsix, disconnect from the internet, and then install it offline. Which vsix did you try?

@rrysolutions
Copy link

rrysolutions commented Mar 27, 2019 via email

@sean-mcmanus
Copy link
Collaborator

@rrysolutions Yeah, I tried those same steps and it works for me. Our source code that does this downloading is all in our open source repo: https://github.com/Microsoft/vscode-cpptools/tree/release . The code just checks for an install.lock file, which is bundled in the offline vsix. So something must be causing the install.lock file to not exist. If you can do your repro and look for what is going on with the install.lock file that could help. The C/C++ output pane is just supposed to output "Finished installing dependencies" and not try to re-download dependencies that are already bundled in the vsix.

@FerhatAkgun
Copy link
Author

@bobbrow Sorry for the late answer.

I can show you what code needs to be debugged (here) and perhaps we can discover what the proxy issue is.

Please let me know what exactly to debug. I didn't do any debugging inside VSCode. Maybe a short instruction would be good.

@bobbrow
Copy link
Member

bobbrow commented Apr 2, 2019

These are the instructions to build and run the extension: https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/Building%20the%20Extension.md

Before pressing F5 to launch the extension, set a breakpoint here: https://github.com/Microsoft/vscode-cpptools/blob/088276b4aff76e728396300df5b756e3b417073a/Extension/src/common.ts#L378

If you have any questions, or if the guide seems unclear, please let me know.

Thank you!

@rrysolutions
Copy link

rrysolutions commented Apr 2, 2019 via email

@rrysolutions
Copy link

rrysolutions commented Apr 2, 2019 via email

@sean-mcmanus
Copy link
Collaborator

@rrysolutions Are you using 0.22.1? We don't have any code that deletes the install.lock, so it must be VS Code itself that is doing it (or some other external process), possibly it's trying to uninstall the extension and install a newer version 0.22.1.

@sean-mcmanus
Copy link
Collaborator

@rrysolutions It sounds like VS Code auto-updated you to 0.22.1 leaving you in some bad state. You should set the extensions.autoUpdate setting to false. We've thought about possibly defaulting the setting to false for users who install the offline vsix, but that would impact all extensions, so we're not sure about that change.

@rrysolutions
Copy link

rrysolutions commented Apr 2, 2019 via email

@FerhatAkgun
Copy link
Author

Hi @bobbrow
I have followed the instructions. I am getting this error after starting debugging by pressing F5:
Did I miss something? According to the page I had to perform only "npm install" inside the Extension director.

Activating extension `ms-vscode.cpptools` failed:  Cannot find module 'd:\tmp\vscode-cpptools-release\Extension\out\src\main'
extensionHostProcess.js:457
Here is the error stack:  Error: Cannot find module 'd:\tmp\vscode-cpptools-release\Extension\out\src\main'
	at Function.Module._resolveFilename (internal/modules/cjs/loader.js:602:15)
	at Function.Module._load (internal/modules/cjs/loader.js:528:25)
	at Function.t._load (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:729:537)
	at Function.t.getExtensionPathIndex.then.a._load (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:691:639)
	at Function.t.getExtensionPathIndex.then.r._load (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:655:197)
	at Module.require (internal/modules/cjs/loader.js:658:17)
	at require (internal/modules/cjs/helpers.js:20:18)
	at Function.i [as __$__nodeRequire] (d:\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:31:542)
	at d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:717:918
	at E._doActivateExtension (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:718:2)
	at E._activateExtension (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:716:772)
	at E.<anonymous> (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:714:224)
	at Generator.next (<anonymous>)
	at n (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:11:176)
	at new Promise (<anonymous>)
	at n (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:10:975)
	at Object.actualActivateExtension (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:713:946)
	at p._activateExtension (d:\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProc

@sean-mcmanus
Copy link
Collaborator

The out/src/main.js should be generated as part of the TypeScript compilation when you do Launch Extension. Do you see that file generated?

@FerhatAkgun
Copy link
Author

@sean-mcmanus No, the file isn't there. There is no out directory at all.
Did I miss an important step? Like I said I just did an "npm install" and loaded the Extension directory into VSCode.

@sean-mcmanus
Copy link
Collaborator

Hmm, I'm not sure what's going on. Did you try doing a Reload Window? Sometimes that fixes issues like this. Or do you see any errors via Toggle Developer Tools? Maybe run "npm update" too? @michelleangela @Colengms Any ideas?

@FerhatAkgun
Copy link
Author

Output of "npm install":

D:\tmp\vscode-cpptools-release\Extension>npm install

[email protected] postinstall D:\tmp\vscode-cpptools-release\Extension
node ./node_modules/vscode/bin/install

Detected VS Code engine version: ^1.30.0
Found minimal version that qualifies engine range: 1.30.0
Fetching vscode.d.ts from: https://raw.githubusercontent.com/Microsoft/vscode/c6e592b2b5770e40a98cb9c2715a8ef89aec3d74/src/vs/vscode.d.ts
vscode.d.ts successfully installed!

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

up to date in 26.164s

@FerhatAkgun
Copy link
Author

Today I tried "npm install" on a different machine. With same results.
I am not sure if it makes any difference but I am downloading the sources from github via ZIP. I don't have GIT on my machines.
One more thing: I have to confgiure proxy via npm config set https-proxy http:https://XXXXX:YYYY to be able to work with npm.

Any hints on how to proceed with this?

@sean-mcmanus
Copy link
Collaborator

@FerhatAkgun The npm install output looks fine. Downloading via zip should be okay as long as the files are unzip afterwards.

Are you using the "Launch Extension" button? Do you see any errors in the Toggle Developer Tools?

@FerhatAkgun
Copy link
Author

@bobbrow @sean-mcmanus
I am not sure what was wrong the previous time but this time it worked.

getHttpsProxyAgent returns:

auth: null
host: "IP-OF-MY-PROXY"
port: 8080
false

Right after that we go back to DownloadFile.
In the function DownloadFile I can see that response.statusCode is 407, which means "proxy authentication required".
In that case we land here:

} else if (response.statusCode !== 200) {
    // Download failed - print error message
    let errorMessage: string = `failed (error code '${response.statusCode}')`;
    return reject(new PackageManagerWebResponseError(response.socket, 'HTTP/HTTPS Response Error', 'DownloadFile', pkg, errorMessage, response.statusCode.toString()));
} else {

Pleas let me know, what else you need.

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Apr 12, 2019

@FerhatAkgun Have you tried the offline installer? Have you tried setting your C_Cpp.updateChannel to "Insiders"? That also does down a different download path and will automatically retry with http.proxySupport set to "off".

We are not reading/using the http.proxyAuthorization setting when we make our http request, so it's possible that might be the bug. We don't currently have time to investigate this proxy scenario, but you could try changing the code to use something like:

    let proxyAuth: any = vscode.workspace.getConfiguration().get("http.proxyAuthorization", "");
    let proxyOptions: any = {
        host: proxyUrl.hostname,
        port: parseInt(proxyUrl.port, 10),
        auth: proxyUrl.auth,
        rejectUnauthorized: strictProxy,
        headers: { "Proxy-Authorization": proxyAuth }
    };

and see if that works for you.

@FerhatAkgun
Copy link
Author

@sean-mcmanus Yes of course. The offline installer is working but this behavior using the "normal" way is obviously a bug.

Even using the offline installer will cause a problem with every new release. Visual Studio Code will try to update the extension. First part of updating will be fine and the second part (downloading the dependencies) will fail again and this will cause a non working state.

I have placed your code snippet inside getHttpsProxyAgent.
The parameter "http.proxyAuthorization" which you are reading returned null, because this was not set in my user settings. I would expect here that this setting in user settings is not required because of the pop-up login prompt for proxy credentials, which is shown at startup.

Anyway I have entered the setting "http.proxyAuthorization" into user settings with the value "Basic Base64OF(USER:PASSWORD)"
It didn't change anything. The behavior is still the same.

@FerhatAkgun
Copy link
Author

Update:
The only way VSCode is able to download the dependencies is by entering the user settings
http.proxy = http:https://username:password@proxy-ip:8080
I would have expected that the parameter http.proxyAuthorization would do the same, without adding the credentials to the parameter above.

@sean-mcmanus
Copy link
Collaborator

So are you saying you think we have a bug we should fix? Or is setting the http.proxy as described a sufficient workaround?

You can also change the extensions.autoUpdate setting to false to avoid auto-updating the offline vsix.

@rrysolutions
Copy link

rrysolutions commented Apr 17, 2019 via email

@FerhatAkgun
Copy link
Author

@sean-mcmanus
In my opinion that's a bug, which should be fixed.

Reason:
VSCode asks at startup the proxy credentials. So why not use them, when it's already known?
The solution "http.proxy" containing the user credentials in plain text is not a good way but can be used as a temporary solution.

@sean-mcmanus
Copy link
Collaborator

@rrysolutions Every release has an offline vsix for it.
@FerhatAkgun Have you tried changing the http.proxySupport setting? When you set the C_Cpp.updateChannel to "Insiders" will automatically retry with that setting set to off, which fixes the download for some users. Do other extensionsl that download separate binaries post-install such as the C# extension work? Other than that, I'm not sure how to fix this, but we'd accept a pull request.

@FerhatAkgun
Copy link
Author

Hi @sean-mcmanus

Switching C_Cpp.updateChannel to "Insiders" doesn't change anything. It still can't download the dependencies.
I have tried also changing http.proxySupport from override to on or off. In all three cases it doesn't change the behavior.

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Apr 25, 2019

@FerhatAkgun If the Insiders or offline vsix is used, then it shouldn't be downloading any dependencies because those vsix's have an install.lock file that we check (assuming you're not running the extension from the TypeScript source). @rrysolutions was saying that the install.lock file was getting deleted for some reason.

@resk8
Copy link

resk8 commented Jun 7, 2019

Any updates on this issues?

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Jun 7, 2019

@resk8 It hasn't been resolved, but I heard that there will be "external changes" that are expected to enable our extension to fix this in the coming months (July?) -- I'm not sure if the change is publically disclosed though so I can't give more info, unless @bobbrow can find where he heard about it.

@bobbrow
Copy link
Member

bobbrow commented Jun 7, 2019

It's this issue: microsoft/vscode#23251. It sounds like they plan to enable this soon, but I haven't confirmed with them as to whether they are on track to deliver it this month or not. When this goes live we will no longer need to download our dependencies anymore.

@resk8
Copy link

resk8 commented Jul 9, 2019

any updates on this? i cant install the newer vscode without having the C++ extension broken when downloading through a proxy

@sean-mcmanus
Copy link
Collaborator

@resk8 No update yet. I asked the VS Code team for an update at microsoft/vscode#23251 .

@amithrc
Copy link

amithrc commented Dec 31, 2019

I disabled the Strict SSL in the File -> Preferences -> Settings, Problem solved!

@Omegastick
Copy link

I'm currently getting this on Ubuntu 16.04, and @amithrc 's fix didn't work.
Does anyone have a workaround?

@Omegastick
Copy link

Letting all the downloads fail tells you to download a version with all the dependencies from the releases page.

Getting a .vsix file from the downloads page and installing with Ctrl+Shift+P Extensions: Install from VSIX... seems to fix the problem.

@pkeir
Copy link

pkeir commented Feb 3, 2020

When I open a simple C++ folder (helloworld.cpp from the tutorial) recently, I get three VS Code popups:

C/C++ Extension: Downloading 1/3: C/C++ language components
C/C++ Extension: Downloading 2/3: ClangFormat (Windows)
C/C++ Extension: Downloading 3/3: Visual Studio Windows Debugger

They all fail. When I originally installed ms-vscode.cpptools I added our proxy to my settings.json; and installed from the command line. I am running VS Code 1.40.2 on Windows 10. I am reminded to update to 1.41.1, but I'd rather not, as I like to use the same setup as my students.

CTRL+SHIFT+B does build a project, but trying to run or debug the code only produces the message "The C/C++ extension is still installing. See the output window for more information." The contents of the output window are below. This all will begin again if I close and reopen VS Code. Does anyone know how to stop this happening?

Updating C/C++ dependencies...

Downloading package 'C/C++ language components (Windows)'  Failed. Retrying... Failed. Retrying... Failed. Retrying...Waiting 8 seconds... Failed. Retrying...Waiting 16 seconds... Failed. Retrying... Done!
Downloading package 'ClangFormat (Windows)'  Failed. Retrying... Failed. Retrying... Failed. Retrying...Waiting 8 seconds... Failed. Retrying...Waiting 16 seconds... Failed. Retrying... Done!
Downloading package 'Visual Studio Windows Debugger'  Failed. Retrying... Failed. Retrying... Failed. Retrying...Waiting 8 seconds... Failed. Retrying...Waiting 16 seconds... Failed. Retrying... Done!

Installing package 'C/C++ language components (Windows)'
Failed at stage: installPackages
Error: end of central directory record signature not found

If you work in an offline environment or repeatedly see this error, try downloading a version of the extension with all the dependencies pre-included from https://github.com/Microsoft/vscode-cpptools/releases, then use the "Install from VSIX" command in VS Code to install it.

@pkeir
Copy link

pkeir commented Feb 5, 2020

With help from here I was able to get past the problem by downloading the latest version of the dependency cpptools-win32.vsix (which is also the correct option for 64-bit), and installing the package within VS Code via:

code --install-extension %USERPROFILE%\Downloads\cpptools-win32.vsix

@bobbrow bobbrow modified the milestones: Backlog, Tracking Apr 16, 2020
@jrray
Copy link

jrray commented Sep 23, 2020

Regarding proxy configuration, this extension currently tries to download https://go.microsoft.com/fwlink/?linkid=2143240 which redirects to https://download.visualstudio.microsoft.com/download/pr/ebeeef98-9fc6-4e24-8db3-1820882eacb4/d3ade0063f4613e9f9556d6f1fa8f056/bin_linux.zip

In our org we used the guidance on https://code.visualstudio.com/docs/setup/network for configuring our proxy, however download.visualstudio.microsoft.com is not on that list of common hostnames.

sean-mcmanus added a commit to sean-mcmanus/vscode-docs that referenced this issue Sep 28, 2020
Add download.visualstudio.microsoft.com to the list of hostnames to allow through a firewall. See microsoft/vscode-cpptools#3335 (comment) .
@sean-mcmanus
Copy link
Collaborator

@jrray Thanks for letting us know. I've created a PR to add download.visualstudio.microsoft.com to the list: microsoft/vscode-docs#4036

@leifwalsh
Copy link

This also seems related to microsoft/vscode#12588. If the cpptools extension could use an extension API to do this download workaround using Chromium's network stack, it would use the same proxy rules that the rest of VS Code does.

@bobbrow
Copy link
Member

bobbrow commented Dec 9, 2021

This will no longer be a problem in version 1.8.0 when all dependencies are bundled with the VSIX per platform. #8152 is the issue tracking that implementation.

@bobbrow bobbrow closed this as completed Dec 9, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug help wanted Can be fixed in the public (open source) repo. Language Service
Projects
None yet
Development

No branches or pull requests

10 participants