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
[email protected]
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 [email protected]:

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?

4
  • 1
    Also FYI, I restarted my machine just to be sure it wasn't some sort of caching issue, and the problem persisted. Commented Feb 25, 2015 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 Commented May 1, 2016 at 20:21
  • 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. Commented May 1, 2016 at 20:29
  • @SeanKilleen i got this error when i tried to add Microsoft.TeamFoundation.Build.Workflow.dll in tool box. any fix?
    – Beingnin
    Commented Jul 17, 2018 at 9:06

12 Answers 12

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

5
  • You saved my day! I lost 3 hours on a bowler ERRCMD and your simple workaround was the solution. Commented Mar 1, 2016 at 13:41
  • Note to others: "Configure external tools" can be found in the Visual Studio options by searching for "git".
    – John
    Commented Apr 22, 2016 at 20:28
  • 3
    it would be better to recommend https in the answer (and not http) Commented Apr 23, 2016 at 8:34
  • 2
    Note for step 3 in this answer: In VS you have to navigate to Tools > Options > Projects and Solutions > External Web Tools
    – Simon
    Commented May 23, 2016 at 9:31
  • Sorry it took so long for me to mark this as the correct answer! I thought I already had. :) Commented Jul 18, 2016 at 17:27
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 = [email protected]:
    [url "https://"]
        insteadOf = git://

2
  • 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
    Commented Dec 17, 2015 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
    Commented Mar 23, 2016 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" %*
    
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
    Commented Jun 11, 2016 at 6: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://
1
  • What if you dont have any other git installed :(
    – labroo
    Commented May 13, 2015 at 17:18
6

With VS 2015, Update 2 : Just install Git

http://git-scm.com/

2
  • 2
    Worked like a dream. Just restart VS after installing Git.
    – rbrayb
    Commented May 4, 2016 at 1:49
  • This is the path to follow. Need to find a way to give 50 upvotes and mark it as the answer...
    – waffles
    Commented Jan 5, 2017 at 20:28
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.

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

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.

1
  • 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 and saw some descrepancies fairly quickly.
    – Mark C.
    Commented Jul 27, 2015 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:[email protected]:8080
    > npm.cmd config set --global http_proxy http.proxy http://proxyuser:[email protected]:8080
    
  2. Configure Git. Add a .gitconfig file located at C:\Windows\Users\%USERNAME%. Then add followings key/value.

    [http]
        proxy = http://proxyuser:[email protected]:8080
    [https]
        proxy = http://proxyuser:[email protected]:8080
    
  3. Configure Bower. Add a .bowerrc file located at C:\Windows\Users\%USERNAME%. Then add followings key/value.

    {
      "proxy": "http://proxyuser:[email protected]:8080",
      "https-proxy": "http://proxyuser:[email protected]: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:[email protected]:8080"
$env:HTTPS_PROXY = "http://proxyuser:[email protected]:8080"
# Fix (some tools uses lowercase env variables)
$env:http_proxy = "http://proxyuser:[email protected]:8080"
$env:https_proxy = "http://proxyuser:[email protected]:8080"
# Git config
git config --global http.proxy http://proxyuser:[email protected]:8080
git config --global https.proxy http://proxyuser:[email protected]:8080
# Npm config
npm config set proxy http://proxyuser:[email protected]:8080
npm config set https-proxy http://proxyuser:[email protected]: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:[email protected]:8080",
  "https-proxy": "http://proxyuser:[email protected]: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:[email protected]:8080"
https_proxy="http://proxyuser:[email protected]:8080"

Et Voilà :)

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

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.

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%[email protected]: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:[email protected]:8080)
  6. Create Variable (Variable name: HTTPS_PROXY, Variable value: http://proxyuser:[email protected]:8080)
  7. Restart Windows

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.