ruby-install icon indicating copy to clipboard operation
ruby-install copied to clipboard

proxy support

Open epinault opened this issue 10 years ago • 16 comments

On OSX Maverick (10.9.1), using bash shell 3.2.51(1), and ruby-install 0.4.0

I love ruby-install but does not seem to work with proxy.

I have my http_proxy and https_proxy correctly and can do a curl manually and get the files.. but does not seem to work when running "ruby-install ruby 2.1.1"

I get bunch of timeout. So I suspect those ENV variable are not passed/defined in the shell executed by ruby-install

epinault avatar Feb 24 '14 18:02 epinault

Did you export those variables, so they will be passed to all sub-processes?

postmodern avatar Feb 24 '14 20:02 postmodern

I did . I exported both http_proxy and https_proxy. Which is why I dont know why it timeout.

Doing a curl in that same terminal to those URL works though. But when ruby-install tries, it is timing out

epinault avatar Feb 25 '14 18:02 epinault

Here is a sample. And I had set the variables using export

% echo $http_proxy http://one.proxy.att.com:8080 Emmanuel ~/apis ☺ 2.1.0p0
% echo $https_proxy http://one.proxy.att.com:8080 Emmanuel ~/apis ☺ 2.1.0p0
% ruby-install ruby 2.1.1

Installing ruby 2.1.1 into /Users/Emmanuel/.rubies/ruby-2.1.1 ... Installing dependencies for ruby 2.1.1 ... ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/openssl-1.0.1f.mavericks.bottle.tar.gz

curl: (7) Failed connect to downloads.sf.net:443; Operation timed out Error: Failed to download resource "openssl" Download failed: https://downloads.sf.net/project/machomebrew/Bottles/openssl-1.0.1f.mavericks.bottle.tar.gz Warning: Bottle installation failed: building from source. ==> Downloading https://www.openssl.org/source/openssl-1.0.1f.tar.gz

curl: (28) Connection timed out after 5148 milliseconds Trying a mirror... ==> Downloading http://mirrors.ibiblio.org/openssl/source/openssl-1.0.1f.tar.gz

curl: (7) Failed connect to mirrors.ibiblio.org:80; Operation timed out Error: Failed to download resource "openssl" Download failed: http://mirrors.ibiblio.org/openssl/source/openssl-1.0.1f.tar.gz Error: readline-6.2.4 already installed Error: libffi-3.0.13 already installed ==> Upgrading 3 outdated packages, with result:

epinault avatar Feb 25 '14 18:02 epinault

Could you just double check that they are listed not only in set | grep -aE "http_proxy|https_proxy" but also in env | grep -aE "http_proxy|https_proxy"?

havenwood avatar Feb 26 '14 01:02 havenwood

I could not reproduce this for on Fedora 19 with bash 4.2 when forcing it to use wget or curl:

wget

$ export http_proxy=http://one.proxy.att.com:8080
$ ./bin/ruby-install --no-install-deps ruby
>>> Installing ruby 2.1.0 into /home/hal/.rubies/ruby-2.1.0 ...
>>> Downloading http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.bz2 into /home/hal/src ...
--2014-02-25 17:08:48--  http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.bz2
Resolving one.proxy.att.com (one.proxy.att.com)... failed: Name or service not known.
wget: unable to resolve host address ‘one.proxy.att.com’

curl

$ export http_proxy=http://one.proxy.att.com:8080
$ ./bin/ruby-install --no-install-deps ruby
>>> Installing ruby 2.1.0 into /home/hal/.rubies/ruby-2.1.0 ...
>>> Downloading http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.bz2 into /home/hal/src ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (5) Could not resolve proxy: one.proxy.att.com; Name or service not known
!!! Download of http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.bz2 failed!

The proxy variables are being passed to curl/wget. Perhaps you also need to specify a user/password for the proxy?

postmodern avatar Feb 26 '14 01:02 postmodern

They seem to be correct for env and set

set | grep -aE "http_proxy|https_proxy" http_proxy=http://one.proxy.att.com:8080 https_proxy=http://one.proxy.att.com:8080

env | grep -aE "http_proxy|https_proxy" http_proxy=http://one.proxy.att.com:8080 https_proxy=http://one.proxy.att.com:8080

And I don t need user or password when I do it manually.

I can see the google page correctly if I do

curl www.google.com -v

<html itemscope="" itemtype="http://schema.org/WebPage"><head><meta content="Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for." name="description"><meta content="noodp" name="robots"><meta itemprop="image" content="/images/google_favicon_128.png"><title>Google</title><script> ...

epinault avatar Feb 26 '14 22:02 epinault

I wonder what running (env | grep -i http_proxy) shows? I suspect the variables are set, but not actually being passed to sub-processes. Also, where are you setting these variables?

postmodern avatar Feb 28 '14 00:02 postmodern

So I set them manually in my terminal. And I suspect the same. That somehow the subprocess are not seeing them. Just don t make sense why. Only thing I can add is that I am on Maverick and Bash.

(env | grep -i http_proxy)
http_proxy=http://one.proxy.att.com:8080

epinault avatar Mar 03 '14 17:03 epinault

+1

tbenade avatar Sep 30 '14 01:09 tbenade

As a workaround, we could add a --proxy option and explicitly pass that to wget/curl.

postmodern avatar Sep 30 '14 01:09 postmodern

that would work for me!

epinault avatar Sep 30 '14 02:09 epinault

me too! Thanks.

tbenade avatar Sep 30 '14 02:09 tbenade

I have the same problem. Any workarounds ?

sanjeevchopra avatar Dec 23 '14 20:12 sanjeevchopra

If anyone wants to submit a PR to pass proxy options to both curl and wget, I'd accept it!

postmodern avatar Dec 25 '15 02:12 postmodern

I hit this issue when ruby-install tries to install via brew. Calling brew directly works.

Installing everything manually with brew and then continuing works.

I think this is due to the following lines:

https://github.com/postmodern/ruby-install/blob/bb5328a6cf28bf1dbe21cc60d0de30e53afea1a1/share/ruby-install/util.sh#L96-L100

sudo -E (preserve environment) might help, but will fail if the user is not allowed to preserve the environment.

skade avatar Jul 04 '16 14:07 skade

As an addition to @skade comment, I tried to preserve proxy settings via sudoers file (/private/etc/sudoers). You'll need to add your settings to env_keep section.

sofaking avatar Jun 16 '17 11:06 sofaking