Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm running 12.04 in a VM, and I am behind a corporate proxy.

I've got the environment variables set (tried both all lower and all upper case for [http|https|ftp]_proxy, as well as not specifying the user:pass but setting http_proxy_[user|pass])

I can access the web via curl/wget, and I have also gotten apt to use my proxy settings.

But I have been unable to get gem to install, or even list, any remote gems.

When I do try, I get the following:

$ sudo gem install hiera
ERROR:  Could not find a valid gem 'hiera' (>= 0) in any repository
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ECONNREFUSED: Connection refused - connect(2) (http://rubygems.org/latest_specs.4.8.gz)

and

$ sudo gem list -r

*** REMOTE GEMS ***

ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ECONNREFUSED: Connection refused - connect(2) (http://rubygems.org/latest_specs.4.8.gz)

I did some searching on StackOverflow and have tried everything that did not require setting up a VPN or tunnel or external programs.

Is there something I am missing, or something about the env variables I have wrong?

update

Forgot to mention, I am able to download gems from my host workstation and install them that way, but I'd prefer to be able to install directly if at all possible. It's a hassle, especially when there are a lot of deps involved.

Also, for what it is worth: $ gem --version 1.8.15

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

The environment is not preserved when using sudo, so the setting of the http_proxy variable alone is ineffective. You need to export the http_proxy variable and then run sudo with the option -E

export http_proxy=...
sudo -E gem list -r
share|improve this answer
    
I set the environment variables in /etc/bash.bashrc, so I thought that would do the trick. It didn't. Adding -E did, however. Many, many thanks. –  Lee Lowder Jul 6 '12 at 17:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.