Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS 2015 + Bower: Does not work behind firewall

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?

like image 547
SeanKilleen Avatar asked Feb 25 '15 17:02

SeanKilleen


3 Answers

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

like image 150
Rogerio Soares Avatar answered Nov 20 '22 07:11

Rogerio Soares


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

like image 43
BrettJ Avatar answered Nov 20 '22 06:11

BrettJ


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" %*
    
like image 7
arcaner Avatar answered Nov 20 '22 08:11

arcaner