33

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:

enter image description here

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?

Community
  • 1
  • 1
SeanKilleen
  • 8,809
  • 17
  • 80
  • 133
  • 1
    Also FYI, I restarted my machine just to be sure it wasn't some sort of caching issue, and the problem persisted. – SeanKilleen Feb 25 '15 at 17:43
  • I'm not behind a firewall, command works perfectly on a CMD prompt but not in VS. I can download anything with NPM but not the safe for bower.Still having the same issue on VS2015 – Davut Gürbüz May 01 '16 at 20:21
  • http://stackoverflow.com/a/31538406/413032 @Rogerio Soares I think his answer is right . Shipped extension git and "`full git`" are different and routeing things to full git fixed for me too. – Davut Gürbüz May 01 '16 at 20:29
  • @SeanKilleen i got this error when i tried to add `Microsoft.TeamFoundation.Build.Workflow.dll` in tool box. any fix? – Beingnin Jul 17 '18 at 09:06

12 Answers12

61

Same problem using VS 2015, my workaround :

  1. Install Git

    http://git-scm.com/

  2. 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://

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

Rogerio Soares
  • 1,613
  • 16
  • 14
13

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://

BrettJ
  • 980
  • 8
  • 15
  • 1
    You answer was exactly what I was looking for. I was curious how to update the config with only the default setup. Thanks. – Shawn Dec 17 '15 at 20:31
  • 1
    The git.exe installed with visual 2015 uses libgit2sharp (c# implementation for libgit2). So using .gitconfig file seems the right way to configure the tooling. It could be usefull too for proxy settings...Regards – NicoD Mar 23 '16 at 14:43
7

The solution that worked for me with VS2015 Release is to :

  1. Install git command line tool.
  2. 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" %*
    
arcaner
  • 91
  • 1
  • 1
  • Worked for me! The key to success was in setting correct path to GIT. Actually, in my case I needed to add just 1 line in the "bower.cmd": "set PATH=C:\Program Files\Git\bin\;%PATH%" – Alex Klaus Jun 11 '16 at 06:12
6

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://
MagicMau
  • 305
  • 3
  • 10
6

With VS 2015, Update 2 : Just install Git

http://git-scm.com/

chinglun
  • 637
  • 5
  • 18
4

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.

L.L.
  • 679
  • 8
  • 14
3

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

pawan nepal
  • 387
  • 2
  • 10
2

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.

  • I'm using VS 2015 and this partially worked. Next to Bower, I am seeing **(restoring...)** and alongside angular and some libraries it still says "not installed", but if I go to `wwwroot` and look in `lib` they are there. Very odd.. And if you're looking to see here I got to where I was, I was following [this AngularJS tutorial](http://www.codeproject.com/Articles/992208/Angular-JS-Application-with-MVC-Web-API-ASPNET-and) and saw some descrepancies fairly quickly. – Mark C. Jul 27 '15 at 17:36
1

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.

  1. Configure Visual Studio external tools to use appropriate settings
  2. 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)

  1. 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
    
  2. 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
    
  3. 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:

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

  1. Install Node.js : NodeJS Website
  2. Install Npm NOTE: Npm is installed automatically by Node.js. (In others words, let node.js install it for you)
  3. Install Git: Git Website Just be sure to check this option to Run Git command in Windows prompt screen shot git installation
  4. Install Bower (globalement) : npm install -g bower
  5. 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"
  6. 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.ps1in a powershell

  • At 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:

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à :)

Community
  • 1
  • 1
rdhainaut
  • 2,659
  • 1
  • 24
  • 34
0

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)

dataCore
  • 1,509
  • 1
  • 16
  • 17
0

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.

Community
  • 1
  • 1
Mike Atkisson
  • 581
  • 4
  • 9
0

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.

To do that on windows 10:

  1. START
  2. Search "Edit the system environment variables"
  3. (in the adanced tab of system properties) click on "Environment Variables...)
  4. (in System variable) click "New..."
  5. Create Variable (Variable name: HTTP_PROXY, Variable value: http://proxyuser:proxypwd@proxy.server.com:8080)
  6. Create Variable (Variable name: HTTPS_PROXY, Variable value: http://proxyuser:proxypwd@proxy.server.com:8080)
  7. Restart Windows
rdhainaut
  • 2,659
  • 1
  • 24
  • 34