Problem
In Visual Studio 2015, using bower, my package restores fail when behind a firewall with an error similar to:
ECMDERR Failed to execute "git ls-remote --tags --heads git://github.com/jzaefferer/jquery-validation.git", exit code of #-532462766
I have updated my git config to use http
instead of git. When I run from my command line, the command is successful:

But Visual Studio or one of its components appears to be using git
instead of http
regardless.
Background & First Attempt to Resolve
Using Visual Studio 2015 and Bower for package management. It works great when not behind a firewall, but when behind a firewall I cannot use the git://
protocol.
The solution -- documented in many other places on SO (example), is to run:
git config --global url."http://".insteadOf git://
I did this, and now my git config -l
looks like:
ore.symlinks=false core.autocrlf=true color.diff=auto color.status=auto color.branch=auto color.interactive=true pack.packsizelimit=2g help.format=html http.sslcainfo=/bin/curl-ca-bundle.crt sendemail.smtpserver=/bin/msmtp.exe diff.astextplain.textconv=astextplain rebase.autosquash=true user.name=Sean Killeen user.email=SeanKilleen@gmail.com url.http://.insteadof=git://
But despite this, either Visual Studio / npm is not respecting my configuration, or is using an old, cached version of it.
Second Attempt to Resolve
Per this thread on npm issue, I saw that npm (which presumably bower is using in VS) uses the git@
syntax. Even though this isn't what I saw in the output, I figured I'd give it a shot.
I ran:
git config --global url."https://github.com/".insteadOf git@github.com:
I then restarted Visual Studio, but the issue still persists. The fix I'd read about was likely never applicable.
Any ideas on how to fix?
Same problem using VS 2015, my workaround :
Install Git
Configure Git to use http instead of git:// with Git Bash
git config --global url."http://".insteadOf git://
Edit (as pointed by g.pickardou) you can use https to be more secure:
git config --global url."https://".insteadOf git://
Configure VS to use the new installed Git over VS Git
Right click on Bower folder (under Dependencies), then select "Configure external tools"
Uncheck "$(DevEnvDir)\Extensions\Microsoft\Web Tools\External\git"
Add a new node with "C:\Program Files (x86)\Git\bin"
Hope this will help someone,
Rogerio
Microsoft's version of git that is installed (at least with VS2015 Update 1) does honor the .gitconfig file, but the tooling that is installed by default does not give you a way to manipulate it (like all the other answers show using git config to fix the problem).
To fix the problem without any extra installations and whatnot, simply create a .gitconfig file in C:\Users\YourUserName and put this content in there (which is the content that git config --global would do but since you dont have a git.exe that can change config, you cannot use that without installing something else you do not really need)
[url "https://github.com/"] insteadOf = git@github.com: [url "https://"] insteadOf = git://
The solution that worked for me with VS2015 Release is to :
- Install git command line tool.
Modify the file C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\bower.cmd with this content:
set PATH=C:\Program Files (x86)\Git\bin\;%PATH% git config --global url."http://".insteadOf git:// git config -l @"%~dp0\node\node" "%~dp0\bower\node_modules\bower\bin\bower" %*
I had the same problem. Apparently the Git.exe that VS2015 CTP ships with does not use .gitconfig. But you can fix it (manually), if you have the git command line tools installed elsewhere.
In C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External
you will need to edit the file bower.cmd
.
Comment out lines 4 and 5:
rem -- set GIT_PATH=%~dp0\git rem -- set PATH=%GIT_PATH%;%PATH%`
This will trigger the command to use the Git you have already installed, which will pick up the local .gitconfig.
Make sure you have set the appropriate git setting:
git config --global url."http://".insteadOf git://
With VS 2015, Update 2 : Just install Git
I had the same problem in Visual Studio 2015 RC (not CTP) and got resolved.
The bower.cmd in 2015 RC does not work well so I needed to disable it in my VS and use the official one installed on my PC. It is easy to do it just right click "Bower" folder in the project and select "configure external tools" then uncheck the section "$(DevEnvDir)\Extensions\Microsoft\Web Tools\External\git".
You may also need to change ".bowerrc" file to make GIT working in the right path for you project.
After doing this, everything works as expected.
The easiest answer which definitely works is here. I had a big headache with this issue. Just download git and install it. While installing choose this option. Run Git from the windows command prompt
I had this same problem in Visual Studio 2015 RC (not CTP). Since this is the only relevant thread I found anywhere, figured I'd add my 2c here.
Expanding on @MagicMau's answer, the lines in bower.cmd referenced don't exist in 2015 RC, so I took a different approach and set the PATH env variable, so that my entire bower.cmd file now looks like this:
set PATH=C:\Program Files (x86)\Git\bin\;%PATH% @"%~dp0\node\node" "%~dp0\bower\node_modules\bower\bin\bower" %*
Note that the first line is what I added, and the second line was the existing content.
The first time I did this, Visual Studio crashed during package restore, but seems to be working after a restart of VS.
It was so painfull to set properly proxy settings. I share my solution.
I work On Windows 10 with Visual Studio 2015. I must set proxy settings when I am at work and remove them at home.
To achieve this, you have 2 solutions.
- Configure Visual Studio external tools to use appropriate settings
- Install tools (node, npm, bower) on your machine and use them (you can set Visual Studio options to use them)
Solution 1 (Configure VS external tools)
Configure Npm. Execute following cmd in Admin prompt.
> cd "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External" > npm.cmd config set --global http_proxy http.proxy http://proxyuser:proxypwd@proxy.server.com:8080 > npm.cmd config set --global http_proxy http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
Configure Git. Add a .gitconfig file located at C:\Windows\Users\%USERNAME%. Then add followings key/value.
[http] proxy = http://proxyuser:proxypwd@proxy.server.com:8080 [https] proxy = http://proxyuser:proxypwd@proxy.server.com:8080
Configure Bower. Add a .bowerrc file located at C:\Windows\Users\%USERNAME%. Then add followings key/value.
{ "proxy": "http://proxyuser:proxypwd@proxy.server.com:8080", "https-proxy": "http://proxyuser:proxypwd@proxy.server.com:8080" }
WARNING: If you have specials characters in your proxy password, you must encode the proxy url. Example:
- username: DOMAIN\user name
- password: P@$$w0rd
- proxy server: 10.80.0.0
- proxy port: 8080
- PROXY URL with authentification: http://DOMAIN%5Cuser+name%3AP%40%24%24w0rd@10.80.0.0:8080
Et Voilà :)
Solution 2 (Install tools on your machine)
I have installed node.js, npm, git and bower globally on my machine (because I need to have more control than just external/tools available in VS).
- Install Node.js : NodeJS Website
- Install Npm NOTE: Npm is installed automatically by Node.js. (In others words, let node.js install it for you)
- Install Git: Git Website Just be sure to check this option to Run Git command in Windows prompt
- Install Bower (globalement) :
npm install -g bower
- Configure Visual Studio Tools to use new tools installed. To do that, Launch Visual Studio => Tools => Options => Open node "Projects and Solutions" => Open External Web Tools => Uncheck "$(DevEnvDir)\Extensions\Microsoft\Web Tools\External\git". Add new "C:\Program Files (x86)\Git\bin"
- Set Proxy settings. Run below scripts in PowerShell as Administrator
I have created 2 powershell scripts for Windows to set/unset proxy settings (Tested on Windows 10).
At work, I need to set proxy settings.
Run
> ./proxy.ps1
in a powershellAt home, I must remove proxy settings.
Run
> ./proxy.disabled.ps1
in a powershell
proxy.ps1
# System Environment variable $env:HTTP_PROXY = "http://proxyuser:proxypwd@proxy.server.com:8080" $env:HTTPS_PROXY = "http://proxyuser:proxypwd@proxy.server.com:8080" # Fix (some tools uses lowercase env variables) $env:http_proxy = "http://proxyuser:proxypwd@proxy.server.com:8080" $env:https_proxy = "http://proxyuser:proxypwd@proxy.server.com:8080" # Git config git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080 git config --global https.proxy http://proxyuser:proxypwd@proxy.server.com:8080 # Npm config npm config set proxy http://proxyuser:proxypwd@proxy.server.com:8080 npm config set https-proxy http://proxyuser:proxypwd@proxy.server.com:8080 # Restart Windows Restart-Computer -Confirm
proxy.disabled.ps1
# Delete System Environment variable Remove-Item env:\HTTP_PROXY Remove-Item env:\HTTPS_PROXY Remove-Item env:\http_proxy Remove-Item env:\https_proxy # Reset Git Config git config --global --unset http.proxy git config --global --unset https.proxy # Reset Npm Config npm config --global delete proxy npm config --global delete https-proxy # Restart Windows Restart-Computer -Confirm
WARNING: If you have specials characters in your proxy password, you must encode the proxy url. Example:
- username: DOMAIN\user name
- password: P@$$w0rd
- proxy server: 10.80.0.0
- proxy port: 8080
- PROXY URL with authentification: http://DOMAIN%5Cuser+name%3AP%40%24%24w0rd@10.80.0.0:8080
WARNING: UNSET PROXY => Some bower settings can be overrided in a .bowerrc file located at C:\Users\%USERNAME%. In others words, if it doesn't work, check if you have a .bowerrc file. Then remove the following keys if they exist:
{ ... "proxy": "http://proxyuser:proxypwd@proxy.server.com:8080", "https-proxy": "http://proxyuser:proxypwd@proxy.server.com:8080", ... }
WARNING: UNSET PROXY => Some nmp/node settings can be overrided in a npmrc file located at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\node\etc. In others words, if it doesn't work, check if you have a npmrc file. Then remove the following key if they exist:
http_proxy="http://proxyuser:proxypwd@proxy.server.com:8080" https_proxy="http://proxyuser:proxypwd@proxy.server.com:8080"
Et Voilà :)
If you have a frendly firewall administrator, aks him to allow access to external git repositories by defining the following firewall-policy:
TCP 9418 (no need for UDP)
Running VS's Bower from the command line with a mapped home folder
The answer given by @Rogerio Soares is a good one and I think many people will find it very useful (myself included).
That said, here at work, the tools I can install are very, very restricted (meaning I can't install another version of Bower without getting permission from lots of people), plus my home directory is mapped to a network share at z:\
by policy. Each time I issued git config --global
to configure git, the config settings would be placed in z:\.gitconfig
. This config file is honored just fine using full-blown Git SCM. Apparently, however, libgit2sharp (used by the version of Git embedded with Visual Studio 2015) needs this file to be at c:\username\.gitconfig
.
So after copying my .gitconfig
file from z:\
to c:\username\
, I was able to run Visual Studio's version of bower directly from the command line.
If you want a global solution.
WARNING: it can impact several proxy settings through different application but it certainly what you want :)
NOTE If you have special characters in your username:password in your proxy settings, you need to URLENCODED them. Example: http://DOMAIN%5Cuser+name%3AP%40%24%24w0rd@proxy.server.com:8080
You must add 2 environment variable.
- HTTP_PROXY: http://proxyuser:proxypwd@proxy.server.com:8080
- HTTPS_PROXY: http://proxyuser:proxypwd@proxy.server.com:8080
To do that on windows 10:
- START
- Search "Edit the system environment variables"
- (in the adanced tab of system properties) click on "Environment Variables...)
- (in System variable) click "New..."
- Create Variable (Variable name: HTTP_PROXY, Variable value: http://proxyuser:proxypwd@proxy.server.com:8080)
- Create Variable (Variable name: HTTPS_PROXY, Variable value: http://proxyuser:proxypwd@proxy.server.com:8080)
- Restart Windows
来源:https://stackoverflow.com/questions/28725727/vs-2015-bower-does-not-work-behind-firewall