KISS

Keep It Simple Stupid

Ruby gem and proxy

| comments

While preparing to try CocoaPods (here is the article), I needed to install the Ruby gem. The command is simple:

1
$ gem install -V cocoapods

However, in my case of being behind a corporate proxy with authentication (here’s how I set it up: article), it didn’t work:

1
2
ERROR:  While executing gem ... (URI::InvalidURIError)
    bad URI(is not URI?): http://domain\user:password@proxy.example.com:8080

According to some doc about gem, it needs information about proxy in a different way:

1
2
3
HTTP_PROXY=proxy.example.com:8080
HTTP_PROXY_USER=domain\user
HTTP_PROXY_PASS=password

Unfortunately, it didn’t work either. gem printed these warnings: “407 Proxy Authentication Required”. I didn’t want to give up though. A fresh thought after browsing the interwebs for a while was to set up a local proxy without authentication.

Luckily, I came across the SquidMan app. On the first start, it installed squid itself. Then, in Preferences leave the default 8080 HTTP port. In Parent tab, enable “Use a parent proxy server” check and enter your information:

Now set up the proxy like this in terminal:

1
2
3
4
$ PROXY='127.0.0.1'; export http_proxy="http://${PROXY}:8080" && \
export https_proxy="$http_proxy" ftp_proxy="$http_proxy" \
HTTP_PROXY="$http_proxy" HTTPS_PROXY="$http_proxy" FTP_PROXY="$http_proxy"; \
unset PROXY

Start the squid and finally, it works! By the way, you can specify the proxy in system settings, so that apps that don’t support proxy with authentication can now use our local proxy.

Comments