Bower install without ssl - bower

I have trouble connecting to sites with ssl, i.e. https. It can successfully download artifacts from the internet if the url begins with http.
bower install will download dependencies via https. Is there anyway make it download via http?

I had troubles with this too, and I couldn't find an elegant way to fix it. My workaround was:
Go to your global npm folder and find the "bower" folder (on Windows 7 that is "C:\Users\\AppData\Roaming\npm\node_modules").
In that folder, search the default.js file placed in node_modules\bower-config\lib\util\default.js
Inside that file you will find a "var defaults". Replace the "registry" url property from "https" to "http".
Yes, I know. This shouldn't be done like this, but at least help me to bypass the connection error.
Hope that helps!

You can change the registry used by Bower in the .bowerrc file. The default registry is: https://bower.herokuapp.com and is defined in node_modules/bower-config/lib/util/default.js (as described by Jean Manuel Arias in his answer).
To override for your project, add a value for the registry setting in .bowerrc. An example file might be:
{
"directory": "<YOUR LIBRARY INSTALL DIRECTORY>",
"registry":"http://bower.herokuapp.com"
}
In the above example, the default https registry is being overridden with the http version. A full list of the available .bowerrc settings can be found at: Bower Spec.
You can do a global override for the current user by creating a %USERPROFILE%\.bowerrc file (for windows, in Linux it is: ~/.bowerrc). Bower follows a similar search path when applying settings to NPM (see npmrc settings). This is probably a better route as it avoids cluttering your project with local settings.

Related

How is Bower working without .bowerrc file

I appreciate this is not a real problem, just curious...
I'm using bower version 1.7.2 and all my projects so far have a .bowerrc file in the main project folder.
On my current project (through an oversight with .gitignore) I lost the .bowerrc file. However bower still works just fine and everything gets created where I want it.
I've read the docs on the Bower site and there is nothing to suggest that it will work without the .bowerrc file, and plenty on stackoverflow suggests that I need the .bowerrc file - ALSO - there isn't a .bowerrc file in the file tree between the project folder and root (although there are plenty around in folders that have different paths)
My question then is: does bower work ok without a .bowerrc file (e.g. defaulting to directory:bower_components) ? or is there a way to see which .bowerrc file my bower is using?
Many thanks for any reply, although completely understandable if you read this and move on, like I said, my problem is that it works, and I don't think it should...
As the docs specify, the .bowerrc file can be either in the project dir, the user home (i.e ~/.bowerrc - depends on your OS) or the root dir.
If you didn't put it anywhere Bower uses defaults as specified here.
And to answer your question - the default directory for bower packages is bower_components
Yes , I tested in my project with out .bowerrc I am able to install packages with bower.If we don't specify the .bowerrc file bower_components directory is creating in the root directly which is default. If we want "bower_components" to be in specific location that should be specified in the .bowerrc file.
For example if we want bower_components folder in "app" folder
bowerrc file should specify directory location : "directory": "app/bower_components",
But while downloading packages from git ,if you computer has any proxy settings that need to be configured in .bowerrc file. If we don't specify the proxy settings in .bowerrc we wont be able to download packages form git.

Setup Grails in GGTS 3.4 behind Proxy

I wish to share the knowledge that how I fix the proxy problem to setup GGTS in my company's PC after I run the setup.exe of GGTS 3.4 downloaded from SpringSource (by googling for a whole day around www ;))
Problem:
When I start to build my hello world project after the IDE installation, GGTS prompts me this error message: "Error Failed to resolve dependencies". How to fix it?
I'll answer my own question:
Go to IE and find the proxy url from the specific proxy file (in Internet
Connection Settings), or just ask your firm's support guys.
Go to your grails' bin folder and run this:
grails add-proxy client "--host=your.proxy.com" "--port=xxxx" "–noproxy='localhost'"
It will give you a line of feedback like: "Added proxy client to \\path.grails\ProxySettings.groovy". Now you should open the file, check the url, port, username & password, and also make sure it contains a second line like this:
currentProxy='client'
There is an article suggesting changing a string in the first line of the ProxySettings.groovy from http.proxyUser to http.proxyUserName. In my own case the proxy doesn't require un/pw so not sure if it is vital or not (source: http://web.archive.org/web/20130910035021/http://jira.grails.org/browse/GRAILS-10097)
Now right click the project in GGTS, Grail Tools > Refresh Dependencies, or just re-create the hello world project. Huray!
ender's answer is fine when you have already run the project at least once, but recently I had a situation where I checked out my project from git on a computer behind a proxy, and I couldn't do "grails add-proxy" because I was behind a proxy and it couldn't get grails dependencies from repos :)
in that case, the solution is to do System.setProperty("http.proxyHost", yourProxy)
in BuildConfig.groovy like this:
grails.project.dependency.resolution = {
System.setProperty("http.proxyHost", yourProxy);
System.setProperty("http.proxyPort", yourProxyPort);
...
}
If you are running GGTS first time behind your company proxy you might get this Error:
Solution:
Go to C:\Users\[your username]\.grails folder, Add a folder name called ProxySettings.groovy.
Expected
Open ProxySettings.groovy file with notepad and add these Two following line:
client=['http.proxyHost':'Proxy Host Address', 'http.proxyPort':'port Number', 'http.proxyUser':'username', 'http.proxyPassword':'password']
currentProxy='client'
Note: Don't Remove single quote.
Final: For Me The content inside file look like Below:
client=['http.proxyHost':'192.150.1.1', 'http.proxyPort':'80', 'http.proxyUser':'Vineet', 'http.proxyPassword':'GoGetHigh']
currentProxy='client'
Edit File ProxySettings.groovy in windows User directory
C:\Users\YourUser
client=['http.proxyHost':'proxy host address', 'http.proxyPort':'proxy host port', 'http.proxyUser':'', 'http.proxyPassword':'']
currentProxy='client'
grails add-proxy client "--host=your.proxy.com" "--port=xxxx" "–noproxy='localhost'"
grails set-proxy client
Then replace maven with ivy in your project's BuildConfig.groovy.
Here is how I fixed the problem for myself for Grails version 2:
Go to C:\Users\\[your username]\\.grails folder, make a file called ProxySettings.groovy.
Inside that ProxySettings.groovy file, add the following two lines:
client=['http.proxyHost':'the proxy host', 'http.proxyPort':'the port number', 'http.proxyUser':'username', 'http.proxyPassword':'password']
currentProxy='client'
For example you can have something like this in the file:
client=['http.proxyHost':'1.1.1.1', 'http.proxyPort':'8080', 'http.proxyUser':'batman', 'http.proxyPassword':'superman']
currentProxy='client'
This does the trick for me and hope this will help you too.

What is the default (official?) Bower registry URL?

What is the main Bower registry URL?
We're trying to set up Bower to use our registry first, then the "official" Bower registry second.
We've created our own little Bower registry based on the endpoints exposed in [bower/registry]1. Works great.
Based on this doc, it looks like we need to create a .bowerrc file with an array of registries like
{
"registry": {
"search": [
"http://myCustomRegistry/api",
"theMainBowerRegistry"
]
}
}
Works fine for use my custom registry, but I can't find the URL for the main Bower registry. Anyone?
The default registry URL is => https://bower.herokuapp.com
Now it is https://registry.bower.io
https://twitter.com/bower/status/908359136601133056
See the explanation https://gist.github.com/sheerun/c04d856a7a368bad2896ff0c4958cb00
The default registry as of now is https://raw.githubusercontent.com/bower/components/1.0.0 for anyone looking in 2017. Entering this into my .bowerrc file solved my ECONNRESET errors. Bower moved away from the herokuapp repository it was using to Github.
The link to Bower's link on Twitter describing this move is linked below.
https://twitter.com/bower/status/796046017133211648
Actually, it's just https://bower.herokuapp.com. /packages is part of the REST API routes, which would create redundant URL segments in your Bower requests (e.g. https://bower.herokuapp.com/packages/search/bootstrap`).

How to run Grails Wrapper (grailsw) behind a proxy?

I tried to run grailsw, but the wrapper cannot connect to download grails-2.2.1-download.zip (creates a 0 byte file instead).
I need to use a proxy server to connect to the internet, where do I configure proxy settings for the Grails Wrapper?
After running grails wrapper, your project directory has a new subdirectory called wrapper, with a file grails-wrapper.properties. You can configure your proxy settings in there, with the following properties:
systemProp.http.proxyHost=
systemProp.http.proxyPort=
systemProp.http.proxyUser=
systemProp.http.proxyPassword=
systemProp.http.nonProxyHosts=
I solved this problem for myself.
It is a two step process
1.a) Back up your JRE_HOME\lib\security folder. This is essential because the below steps might corrupt cacerts file under jre.
1.b) You need to install the ssl public key of Github.com to your local file system. To do that you have to use the InstallCert.java program( Link to InstallCert.java )
It is supposed to be run as java InstallCert github.com
and when it asks to enter cert number you need to enter 1
It will create a file with name "jssecacerts" in the current directory
1.c) But this program will not work because it does not know about how to authenticate with proxy. For this you need the code from SSLSocketClientWithTunneling page
Use the above two and create a program that tunnels through the proxy retrieves the ssl key and writes a file called jssecerts
2) Update your grails.bat with addtional options. Add these options to the %JAVA_EXE% command line. Paste them after %DEFAULT_JVM_OPTS%
-Dhttp.proxyHost=YourproxyURL -Dhttp.proxyPort=YourproxyPort -Dhttps.proxyHost=YourproxyURL -Dhttps.proxyPort=YourproxyPort -Dhttp.proxyUser=YourProxyUserID -Dhttp.proxyPassword=YourProxyPassword -Dhttps.proxyUser=YourProxyUserID -Dhttps.proxyPassword=YourProxyPassword -Djavax.net.ssl.trustStore=path-to-your-jssecacerts-created-in-step-1

Choose bower install directory

This is a follow-up to this question. I'm using bower 0.7.1, and still cannot get the components to be installed anywhere else than in the components folder.
I tried adding the following line to my component.json, as per this PR:
"componentsDirectory": "public/components"
But it will still install in ./components.
I tried to create a .bowerrc file next to component.json:
{
"directory" : "public/components"
}
But I get this error when running bower install:
Error: Unable to parse local .bowerrc file: Unexpected token }
Any idea?
Actually the .bowerrc file does work, this was an issue with my IDE not saving the file properly:
{
"directory" : "public/components"
}
I'm still wondering why componentsDirectory still doesn't work in component.json, though.
While you can happily use Bower to manage the dependencies of your own personal projects, primarily the component.json is a description of your project for other people. If you share a component through the Bower registry the component.json goes with it to describe the dependencies. That is why your own local preferences like where to install components don't belong in there.
Another way to change installation directory temporarily is using --config option in command line:
bower install jquery --config.directory=/path/to/your/components
If you are creating this file in Notepad++, make sure the Encoding is set to "Encode in UTF-8 without BOM" and save as file type "Any".

Resources