"bad response Proxy Authentication" when using gem on Windows - ruby

When I try to add source:
C:\>gem source --verbose --add http://gemcutter.org
GET http://gemcutter.org/specs.4.8.gz
407 Proxy Authentication Required
Error fetching http://gemcutter.org:
bad response Proxy Authentication Required 407 (http://gemcutter.org/specs.4.8.gz)
p.s. my Windows XP client accesses the web via a proxy, so I tried:
C:\>gem -v
1.8.10
C:\>gem source --verbose --http-proxy http://192.168.10.24:3128 --add http://gemcutter.org
but returns the same error. How can I fix it?

You need to put the proxy username and password in there somehow.
On *nix machines, gem looks for an environment variable named HTTP_PROXY. You can set this variable on windows too.
Run SET HTTP_PROXY=http://%USER%:%PASSWORD%#192.168.10.24:3128 before you run your gem command.
Another possibility is to install another "proxy" on your computer itself. See How do I update Ruby Gems from behind a Proxy (ISA-NTLM) and http://ntlmaps.sourceforge.net/ for details on this.
You might be able to use rubysspi. See the instructions here.

Related

bundle install gives error Bundler::HTTPError Could not fetch specs from http://rubygems.org/

Running bundle install gave the following
Fetching source index from https://rubygems.org/
Retrying fetcher due to error (2/4): Net::HTTPServerException 403 "Forbidden"
Retrying fetcher due to error (3/4): Net::HTTPServerException 403 "Forbidden"
Retrying fetcher due to error (4/4): Net::HTTPServerException 403 "Forbidden"
Could not fetch specs from https://rubygems.org/
Followed this and changed to http in Gemfile. Problem Still exists. I didn't install any other ruby version. Default on Mac Ruby version : ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18], bundle version 2.0.1.
Running bundle update then gave
Authentication is required for http://rubygems.org/. Please supply credentials for this source. You can do this by running: bundle config http://rubygems.org/ username:password
No idea what the credentials should be, but I signed up at rubygems.org and used that username/password (Pardon if that was silly) and got
Bad username or password for http://username#rubygems.org/. Please double-check your credentials and correct them.
Followed this and turned off IPV6 and still same problem.(If anything the errors showed up a little faster)
Infact now realised none of the gem command works and gives errors like
gem install jekyll bundler
ERROR: While executing gem ... (Net::HTTPServerException)
403 "Forbidden"
While I did install jekyll and bundler yesterday. Today I ran bundle exec jekyll serve and got
Could not find gem 'minima (~> 2.0)' in any of the gem sources listed in your Gemfile.
Run bundle install to install missing gems.
Hence, it all started with trying to get Jekyll working.
OS : MacOS(10.14.3)
So I have a proxy in my organization's network which I knew would cause problems so I was infact using a different network. I finally tried to comment out the proxy settings in my .bash_profile, and it was still giving the same errors. I shut down the system and then tried again and it worked.
Such a bummer. Anyway I'm not deleting the question hoping for a better work around than this. I mean if every time I want to use gem I have to do this it's kind of a hassle.
Using http instead of https in your Gemfile should do the trick.
Use:
http://rubygems.org
Disable IPv6 and HTTPS .
(Windows) -
Open Gem file and replace :
source "https://rubygems.org"
with
source "http://rubygems.org"
then , Go To Control Panel\Network and Internet\Network Connections
Right Click on your adapter , and select properties .
Untick IPv6 there

Install Ruby gems behind NTLM proxy

I am trying to install ruby gems behind NTLM proxy. My OS is Windows 7. These are all the solutions that I tried, non of them working.
Using HTTP_PROXY:
set HTTP_PROXY=http://domain\user:pass#proxy.company.com:8080
set HTTP_PROXY=http://domain\\user:pass#proxy.company.com:8080
set HTTP_PROXY=http://domain\\user:pass#proxy.company.com:8080/
All above response bad URI
set HTTP_PROXY=http://user:pass#proxy.company.com:8080
Response: bad response Proxy Authentication Required 407
Using -p or --http-proxy parameter from Ruby
gem install -p "http://domain\user:pass#proxy.company.com:8080" rake
gem install -p "http://domain\\user:pass#proxy.company.com:8080" rake
gem install -p http://domain\user:pass#proxy.company.com:8080 rake
gem install -p http://domain\\user:pass#proxy.company.com:8080 rake
gem install --http-proxy "http://domain\user:pass#proxy.company.com:8080" rake
gem install --http-proxy "http://domain\\user:pass#proxy.company.com:8080" rake
gem install --http-proxy http://domain\user:pass#proxy.company.com:8080 rake
gem install --http-proxy http://domain\\user:pass#proxy.company.com:8080 rake
All response: invalid argument
Try all the options above without the domain or encode the \ to %5C will receive reponse: bad response Proxy Authentication Required 407
What did I miss in these command or setup?
You can use cntlm http://cntlm.sourceforge.net/, so that you have a local proxy that requires no authentication (which in turns connects to the ntlm proxy).
Also: How do I update Ruby Gems from behind a Proxy (ISA-NTLM)
Seems like there is no fix for the moment to make work rubygems behind an NTLM proxy: https://github.com/rubygems/rubygems/issues/360.
Anyway, I still found no way to fix it and the only solution is to download a gem (take care of all its dependencies) and install locally (from inside a folder where the gem was saved to):
gem install your_gem_name --local
I have stumbled on a more easier and possibly safer solution that works not just for git but also any command based installers
Rubygems in ruby
npm in node
One solution running all your traffic from command line is proxied with authentiction.
Wont expose your password in the user:password#domain:port format
Solution:
Download Fiddler, It has a built in way to add authentication headers to all requests.
Once running menu Rules-> Automatically Authenticate (Tick that)
Then for git
git config --global http.proxy http://localhost:8888
git config --global https.proxy http://localhost:8888
Thats it!

"Could not find a valid gem in any repository" (rubygame and others)

I've been trying to install this 'rubygame' gem for some time, but whenever I use the command
gem install rubygame
it will give an error:
ERROR: Could not find a valid gem 'rubygame' (>= 0) in any repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ETIMEDOUT: Connection timed out - connect(2) (http://rubygems.org/latest_specs.4.8.gz)
I've also tried other gems but with similar results:
ERROR: Could not find a valid gem 'rake' (>= 0) in any repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ETIMEDOUT: Connection timed out - connect(2) (http://rubygems.org/latest_specs.4.8.gz)
I've already made sure I have an internet connection, and have already tried reinstalling both ruby and rubygems (currently using ruby 1.8, rubygems 1.7.2). Googling didn't help me at all. I would be very grateful if anyone can solve my problem. My sources list only shows http://rubygems.org
Check if you have "https://rubygems.org/" as a source to find gems at:
$ gem sources
*** CURRENT SOURCES ***
https://rubygems.org/
If not, you should be able to add it with
$ gem sources --add https://rubygems.org/
https://rubygems.org/ added to sources
Here are docs for the gem source command.
You can also add the source you want on the command whenever you have troubles using https, like this:
gem install GEMNAME --source http://rubygems.org
It's better to fix the SSL problem though.
are you behind any proxy?
check your browser for proxy that you might use:
execute the command: gem install xxx --http-proxy=http://user:password#server and you should be good to go.
You don't have an Internet connection to rubygems.org.
This happens sometimes if the site is down or blocked.
This command can show you if your connection has a way to reach rubygems.org:
traceroute rubygems.org
Maybe you should try
gem list -r
then
gem install -r rubygame
Also note that with rvmon MacosX (Lion in my case) you should install ruby-1.9.3-p194 (for Xcode 4.x compiler considerations) then
rvm rubygems current
and in my case I had to use
rvm use ruby-1.9.3-p194#global
(which contains bundler, rake, rubygems-bundlerand rvm)
and not
rvm use ruby-1.9.3-p194
(which is empty)
Can you post your versions?
ruby -v
#=> ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
gem -v
#=> 1.8.19
If your gem command is not current, you can update it like this:
gem update --system
To see if you can connect to rubygems.org using Ruby:
require 'net/http'
require 'uri'
puts Net::HTTP.get URI.parse('https://rubygems.org')
If yes, that's good.
If no, then somehow Ruby is blocked from opening a net connection. Try these and see if any of them work:
curl https://rubygems.org
curl https://rubygems.org --local-port 1080
curl https://rubygems.org --local-port 8080
env | grep -i proxy
If you're using a company machine, or within a company firewall, or running your own firewall, you may need to use a proxy.
For info on Ruby and proxies see
http://www.linux-support.com/cms/http-proxies-and-ruby/
I have fixed this issue using the proxy command option of gem install. It has the following format:
$ gem install --http-proxy http://201.187.107.19:8080 rubygame
Note, the IP address and the port number refers to a proxy. You should search for a proxy list and use one of the proxies there.
This is site with proxies: http://www.cybersyndrome.net/pla5.html
Also, I have to try 7 or 8 different proxies in order to succeed. Do not give up.
Use :
gem sources --add http://rubygems.org/
Do you want to add this insecure source? [yn] [YES]
then use
gem install sass
and done
I know this is a little late, but I was also having this issue a while ago. This is what worked for me:
REALLY_GEM_UPDATE_SYSTEM=1
sudo gem update --system
sudo gem install rails
Hope this helps anyone else having this issue :)
I have tried most of the solutions suggested here but I had no luck.
I found a solution that worked for me, which was manually updating the gemfile to 2.6.7.
The guide on how to do is in guides.rubygems.org: installing-using-update-packages
Download rubygems-update-2.6.7.gem to your C:\
Now, using your Command Prompt:
C:\>gem install --local C:\rubygems-update-2.6.7.gem
C:\>update_rubygems --no-ri --no-rdoc
After this, gem --version should report the new update version (2.6.7).
You can now safely uninstall rubygems-update gem:
C:\>gem uninstall rubygems-update -x
Removing update_rubygems
Successfully uninstalled rubygems-update-2.6.7
The reason why this did not work before was because server used certificates SHA-1, now this was updated to SHA-2.
For what it is worth I came to this page because I had the same problem. I never got anywhere except some IMAP stuff that I don't understand. Then I remembered I had uninstalled privoxy on my ubuntu (because of some weird runtime error that mentioned 127.0.0.1:8118 when I used Daniel Kehoe's Rails template, https://github.com/RailsApps/rails3-application-templates [never discovered what it was]) and I hadn't changed my terminal to the state of no system wide proxy, under network proxy.
I know this may not be on-point but if I wound up here maybe other privoxy users can benefit too.
check your DNS settings ...I was facing similar problem ... when I checked my /etc/resolve.config file ,the name server was missing ... after adding it the problem gets resolved
This worked for me to bypass the proxy definitions:
1) become root
2) gem install -u gem_name gem_name
Hope you can work it out
I tried to install a gem which is for JRuby only, running into the same error. Using jruby's command worked then:
jruby -S gem install some_jruby_gem
If you are running behind the any firewall(if firewall blocking gem installation). just try following command it works.
gem install --http-proxy http://username:pwd#server:port gem
Make sure you type the command from the "App" Directory
It is a permission issue.
try with sudo

How to bundle install a git gem behind a proxy?

I am behind a proxy and I have a git gem in my Gemfile. How can I configure bundler to use git with the appropriate proxy parameters?
I already have $http_proxy appropriatelly set, as well as my .gemrc . Still, it doesn't work.
Are you sure you are using git-over-http? I.e. does your git URL start with http://?
Remember that setting http_proxy for your user wont be preserved when you execute sudo - to preserve it, do:
sudo -E yourcommand
I got my gem install working by first installing cntlm local proxy. The instructions here is succinct : http://www.leg.uct.ac.za/howtos/use-isa-proxies
Instead of student number, you'd put your domain username
To use the cntlm local proxy, exec:
sudo gem install --http-proxy http://localhost:3128 theGem

Bundler http auth support

does anyone know if Bundler supports http auth? I'm pretty sure rubygems does (I think i read that somewhere) but I don't see anywhere in the docs where I might specify a username/pwd for a particular repo
I'm trying to run my own private gem server so as not to expose sensitive code
According to https://github.com/carlhuda/bundler/issues/300 you can set the proxy settings the same as in rubygems.
set HTTP_PROXY=http://[username]:[password]#[proxyserver]:[port]
http://dan-webb.co.uk/wordpress/?p=11
OR
# cat $HOME/.gemrc
gem: --source http://[username]:[password]#[proxyserver]:[port]/[DIRECTORY]
http://www.sun.com/bigadmin/content/submitted/ruby_http.jsp
Bundler version 1.6 added HTTP auth in bundle config.

Resources