In Visual Studio 2015, using bower, my package restores fail when behind a firewall with an error similar to:
ECMDERR Failed to exec
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:
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://
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 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:
Et Voilà :)
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).
npm install -g bower
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 powershell
At home, I must remove proxy settings.
Run > ./proxy.disabled.ps1
in a powershell
# 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
# 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à :)
Same problem using VS 2015, my workaround :
Install Git
http://git-scm.com/
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
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)
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.