Problem in Ruby Gems Source Installation - ruby

I get the following error while performing the following commmand of adding rubygems.orgs as the gem source.
I am having Windows XP.
C:\>gem source --add http://rubygems.org
Error fetching http://rubygems.org:
SocketError: getaddrinfo: no address associated with hostname. (http://r
ubygems.org/specs.4.8.gz)
Please help me out and thanks in advance

It could be a DNS issue, as shown in this thread.
$ host rubygems.org rubygems.org has address 72.4.120.124
rubygems.org mail is handled by 10 izmunuti.segment7.net.
rubygems.org mail is handled by 20 ziz.jijo.segment7.net.
I get the same result, i can ping and lookup the URL just fine, I just can't add it to my gem source list :-(
I just accurately tried again, and now I successfully added rubygems as a source. May just have been a network problem.
If not, try a full ruby reinstall as suggested here and check out your remote sources.

If anyone gets this on a linux box the solution I found was to use one of Google's nameservers in my /etc/resolv.conf file.
nameserver 8.8.8.8

Related

Unable to vagrant box add laravel/homestead (errno 60 / SSL read)

Basically I got this error seconds after I trigger
vagrant box add laravel/homestead in my terminal.
What's more interesting, after second failed attempt, the error message is a little bit different (as you see).
Error number 60 is somehow related to SSL. Since I'm running this command via terminal, I really have no idea how to investigate this issue. Can somebody give me any hints? May it be related to poor wireless internet connection?
slick-mac:~ slick$ vagrant version
Installed Version: 1.7.4
Latest Version: 1.7.4
You're running an up-to-date version of Vagrant!
If you get an SSL issue, you can try to add the box using the insecure option
vagrant box add --insecure laravel/homestead
--insecure When present, SSL certificates won't be verified if the URL is an HTTPS URL
I'm deliberately posting this as an answer because probably I've found solution. So far it's still downloading.
What I did:
1. I removed temp stuff
rm -rf ~/.vagrant.d/tmp/
2. I started the download again
vagrant box add laravel/homestead
So far it's still OK despite of my slow internet connection. If that won't work I will try Frederic's solution.
EDIT:
After 80% it failed. (no --insecure) param.
These SSL related issues are not from client side. It is originated from the source. We can do nothing from our side. I have tried with Windows OS, Mac OS X and manual download with many browsers and even with downloaders, no luck. Somehow I managed to download with mobile browser on 4G. I was wondering why not upload this to place everyone can download.
You can find a mirror here on my Google Drive. It is a copy of laravel/homestead 0.5.0. Have fun.
I encountered the same issue. Adding --insecure argument, specifying url, https://atlas.hashicorp.com/laravel/boxes/homestead, and removing the tmp file beforehand did not work for me.
Brutely repeating download attempts to download did however. Thus, in my case, nothing to do with SSL.
what Worked for me was emptying the temp first then running the following command:
vagrant box add --insecure laravel/homestead
it looks like after failing once ,it couldn't resume correctly until the temp was emptied .
hope this helps.

Error installing the svn2git gem (EADDRNOTAVAIL)

I'm trying to use svn2git on a test PC before using it with my real projects.
So I have tortoiseSVN installed and a project working with SVN in a local repository (I work on my test only in local network, the PC is not connected to other item).
I installed GIT for my tests (V 1.9.5-preview20150319), and Ruby in V2.2.2 to use gem.
I followed this link :http://www.troyhunt.com/2014/08/migrating-from-subversion-to-git-with.html
but when i type the command : "gem install svn2git", it does not work, I have the following error :
ERROR : while executing gem ... (Errno::EADDRNOTAVAIL)
The requested address is not valid in its context - connect(2) for "0.0.0.0" port 53
I downloaded svn2git-2.3.2 and placed it in Ruby22\lib\ruby\gems\2.2.0\gems\svn2git-2.3.2
If you have any suggestion..
Thanks
Was also struggling with that.
You need to install a loopback adapter on Windows. Search for it, there's lots of guides on DuckDuckGo on how to do that.

While I try install 'gem install watir' I get this error

While I try to install the watir, I have the following error, Can anyone please guide me how to resolve this problem?
C:\>gem install watir -v 4.0.2
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ECONNRESET: An existing connection was forcibly closed by the remote
host. - SSL_connect (https://api.rubygems.org/api/v1/dependencies?gems=watir-webdriver)
I am using Ruby 2.1.5 and WATIR 4.0.2.
Whenever you see the following error:
Errno::ECONNRESET: An existing connection was forcibly closed by the remote host.
But you can access internet normally, it has a high possibility that your request has been blocked by the Chinese governments' Great Firewall.
In such case, you can try changing your DNS settings to 8.8.8.8(Google) if you are not in China, or you can use Taobao's mirror otherwise.
See ruby.taobao.org for details, if you understand Chinese.
The worst case is that the IP of the server serving the gem is blocked by Great Firewall. It will intercept TCP handshakes by send RST packets to both your browser/client and the server. In such case, you have to use some proxy or VPN to get your job done.
You need to change your rails ssl certificate

i cannot install haml using "gem install haml"

i have already downloaded ruby 2.2.1 and in command prompt i hv tried the command
gem install haml
but error is coming like:
ERROR: Could not find a valid gem 'haml' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - Errno::ECONNREFUS ED: No connection could be made because the target
machine actively refused it.
- connect(2) for "api.rubygems.org" port 443 (https://api.rubygems.org/specs.4.8 .gz)
It might be because of the firewall company have put up in every system. I have gone through trying different proxies picked up from different websites. Can anybody tell how to install or use haml/sass?
Company firewalls, the bane of many a developer's existence.
The best thing you can do:
Talk to the local networking team and get it unblocked for direct access.
If that fails:
Do they have a proxy you can use? gem will honor proxy variables, so if you get access to one, you can do an export https_proxy="http://someaddress:someport", and then your command should work.
If that also fails
Now we're left with circumventing the network policies - Be careful, as this could get you in trouble.
Options include:
Getting an external proxy that allows port 80 (it sounds like 80 works from your question). You could set up a squid instance on your home machine and access it that way via the variable method above.
Doing an SSH tunnel through a machine that does have unrestricted internet access, and using tsocks to tunnel through there.
There are others, but these two are relatively easy to set up.
I must emphasize here, be careful! Even if your networking group is impeding your ability to do your job, either get your boss's support, or be as stealthy as possible and discontinue use of these tools once you have what you need.
If it's a rails project, you can try to change the first line of your Gemfile from source 'https://rubygems.org' to source 'http://rubygems.org'.
If you are using a ruby project, try to download gem without https, like : gem install -s http://rubygems.org haml

How do I update Ruby Gems from behind a Proxy (ISA-NTLM)

The firewall I'm behind is running Microsoft ISA server in NTLM-only mode. Hash anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method?
... or am I just being lazy?
Note: rubysspi-1.2.4 does not work.
This also works for "igem", part of the IronRuby project
For the Windows OS, I used Fiddler to work around the issue.
Install/Run Fiddler from www.fiddler2.com
Run gem:
$ gem install --http-proxy http://localhost:8888 $gem_name
I wasn't able to get mine working from the command-line switch but I have been able to do it just by setting my HTTP_PROXY environment variable. (Note that case seems to be important). I have a batch file that has a line like this in it:
SET HTTP_PROXY=http://%USER%:%PASSWORD%#%SERVER%:%PORT%
I set the four referenced variables before I get to this line obviously. As an example if my username is "wolfbyte", my password is "secret" and my proxy is called "pigsy" and operates on port 8080:
SET HTTP_PROXY=http://wolfbyte:secret#pigsy:8080
You might want to be careful how you manage that because it stores your password in plain text in the machine's session but I don't think it should be too much of an issue.
This totally worked:
gem install --http-proxy http://COMPANY.PROXY.ADDRESS $gem_name
I've been using cntlm (http://cntlm.sourceforge.net/) at work. Configuration is very similar to ntlmaps.
gem install --http-proxy http://localhost:3128 _name_of_gem_
Works great, and also allows me to connect my Ubuntu box to the ISA proxy.
Check out http://cntlm.wiki.sourceforge.net/ for more information
I tried some of these solutions, and none of them worked. I finally found a solution that works for me:
gem install -p http://proxy_ip:proxy_port rails
using the -p parameter to pass the proxy. I'm using Gem version 1.9.1.
Create a .gemrc file (either in /etc/gemrc or ~/.gemrc or for example with chef gem in /opt/chef/embedded/etc/gemrc) containing:
http_proxy: http://proxy:3128
Then you can gem install as usual.
This solved my problem perfectly:
gem install -p http://proxy_ip:proxy_port compass
You might need to add your user name and password to it:
gem install -p http://[username]:[password]#proxy_ip:proxy_port compass
If you are having problems getting authenticated through your proxy, be sure to set the environment variables in exactly the format below:
set HTTP_PROXY=some.proxy.com
set HTTP_PROXY_USER=user
set HTTP_PROXY_PASS=password
The user:password# syntax doesn't seem to work and there are also some badly named environment variables floating around on Stack Overflow and various forum posts.
Also be aware that it can take a while for your gems to start downloading. At first I thought it wasn't working but with a bit of patience they started downloading as expected.
Quick answer : Add proxy configuration with parameter for both install/update
gem install --http-proxy http://host:port/ package_name
gem update --http-proxy http://host:port/ package_name
I tried all the above solutions, however none of them worked. If you're on linux/macOS i highly suggest using tsocks over an ssh tunnel. What you need in order to get this setup working is a machine where you can log in via ssh, and in addition to that a programm called tsocks installed.
The idea here is to create a dynamic tunnel via SSH (a socks5 proxy). We then configure tsocks to use this tunnel and to start our applications, in this case:
tsocks gem install ...
or to account for rails 3.0:
tsocks bundle install
A more detailed guide can be found under:
http://blog.byscripts.info/2011/04/bypass-a-proxy-with-ssh-tunnel-and-tsocks-under-ubuntu/
Despite being written for Ubuntu the procedure should be applicable for all Unix based machines. An alternative to tsocks for Windows is FreeCap (http://www.freecap.ru/eng/). A viable SSH client on windows is called putty.
Posts abound regarding this topic, and to help others save hours of trying different solutions, here is the final result of my hours of tinkering.
The three solutions around the internet at the moment are:
rubysspi
apserver
cntlm
rubysspi only works from a Windows machine, AFAIK, as it relies on the Win32Api library. So if you are on a Windows box trying to run through a proxy, this is the solution for you. If you are on a Linux distro, you're out of luck.
apserver seems to be a dead project. The link listed in the posts I've seen lead to 404 page on sourceforge. I search for "apserver" on sourceforge returns nothing.
The sourceforge link for cntlm that I've seen redirects to http://cntlm.awk.cz/, but that times out. A search on sourceforge turns up this link, which does work: http://sourceforge.net/projects/cntlm/
After downloading and configuring cntlm I have managed to install a gem through the proxy, so this seems to be the best solution for Linux distros.
A workaround is to install http://web.archive.org/web/20060913093359/http://apserver.sourceforge.net:80/ on your local machine, configure it and run gems through this proxy.
Install: Just download apserver 097 (and not the experimental 098!) and unpack.
Configure: Edit the server.cfg file and put the values for your MS proxy in PARENT_PROXY and PARENT_PROXY_PORT. Enter the values for DOMAIN and USER. Leave PASSWORD blank (nothing after the colon) – you will be prompted when launching it.
Run apserver: cd aps097; python main.py
Run Gems: gem install—http-proxy http://localhost:5865/ library
I am working behind a proxy and just installed SASS by downloading directly from http://rubygems.org.
I then ran sudo gem install [path/to/downloaded/gem/file]. I cannot say this will work for all gems, but it may help some people.
This worked for me in a Windows box:
set HTTP_PROXY=http://server:port
set HTTP_PROXY_USER=username
set HTTP_PROXY_PASS=userparssword
set HTTPS_PROXY=http://server:port
set HTTPS_PROXY_USER=username
set HTTPS_PROXY_PASS=userpassword
I have a batch file with these lines that I use to set environment values when I need it.
The trick, in my case, was HTTPS_PROXY sets. Without them, I always got a 407 proxy authentication error.
If you are on a *nix system, use this:
export http_proxy=http://${proxy.host}:${port}
export https_proxy=http://${proxy.host}:${port}
and then try:
gem install ${gem_name}
rubysspi-1.3.1 worked for me on Windows 7, using the instructions from this page:
http://www.stuartellis.eu/articles/installing-ruby/
If you want to use SOCKS5 proxy, you may try rubygems-socksproxy https://github.com/gussan/rubygems-socksproxy.
It works for me on OSX 10.9.3.
If behind a proxy, you can navigate to Ruby downloads, click on Download, which will download the specified update ( or Gem ) to a desired location.
Next, via Ruby command line, navigate to the downloaded location by using : pushd [directory]
eg : pushd D:\Setups
then run the following command: gem install [update name] --local
eg: gem install rubygems-update --local.
Tested on Windows 7 with Ruby update version 2.4.1.
To check use following command : ruby -v
Rather than editing batch files (which you may have to do for other Ruby gems, e.g. Bundler), it's probably better to do this once, and do it properly.
On Windows, behind my corporate proxy, all I had to do was add the HTTP_PROXY environment variable to my system.
Start -> right click Computer -> Properties
Choose "Advanced System Settings"
Click Advanced -> Environment Variables
Create a new System variable named "HTTP_PROXY", and set the Value to your proxy server
Reboot or log out and back in again
Depending on your authentication requirements, the HTTP_PROXY value can be as simple as:
http://proxy-server-name
Or more complex as others have pointed out
http://username:password#proxy-server-name:port-number
for anyone tunnelling with SSH; you can create a version of the gem command that uses SOCKS proxy:
Install socksify with gem install socksify (you'll need to be able to do this step without proxy, at least)
Copy your existing gem exe
cp $(command which gem) /usr/local/bin/proxy_gem
Open it in your favourite editor and add this at the top (after the shebang)
require 'socksify'
if ENV['SOCKS_PROXY']
require 'socksify'
host, port = ENV['SOCKS_PROXY'].split(':')
TCPSocket.socks_server = host || 'localhost'
TCPSocket.socks_port = port.to_i || 1080
end
Set up your tunnel
ssh -D 8123 -f -C -q -N user#proxy
Run your gem command with proxy_gem
SOCKS_PROXY=localhost:8123 proxy_gem push mygem

Resources