We have a proxy in work that prevents connections from being made out directly. I found out about the awesome MacPorts program, which is a bit like apt for OSX. It pulls backports from a repository and installs them for you.

There’s not a lot to the tool’s installation if you live on the open web, but I needed to do some stuff to get it working with our squid proxy.

If you run sudo port selfupdate, and get an error that says ‘port selfupdate failed: Couldn’t sync the ports tree’ or something like that, chances are your proxy is blocking rsync.

There are three steps. The prerequisites required for this to work are that you have the proxy address, admin access to your mac, and that the proxy supports the rsync port (873/tcp).

You can test the connectivity by going to http://rsync.macports.org:873, you should get the following error:

@RSYNCD: 30.0
@ERROR: protocol startup error

Step 1

If that works ok, then you need to set up the sudo environment for osx to let proxy environment settings through. First, edit your sudoers file with:
sudo visudo
Do not just edit /etc/sudoers

You need to append these lines:

Defaults env_keep += "http_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY RSYNC_PROXY"
Defaults env_keep += "ALL_PROXY NO_PROXY"

Step 2

Now, you need to set your http proxy
export http_proxy=http://proxy.example.com:8080
where 8080 is the port number of the proxy

Step 3

By Default, port uses rsync to manage its updates. RSync can use a proxy environment setting (man rsync for mre)
export RSYNC_PROXY=proxy.example.com:8080
Note the rsync proxy capitalisation, and the fact that it does not need http://

That should do it. You can then run selfupdate to get port to the latest version.

The hard way

If that doesn’t work, you can have a look at these instructions for replace rsync with subversion:
Syncing with SVN in Macports

Popularity: 100% [?]


  • BROWSE / IN OSX
  • RELATED / YOU MIGHT FIND THESE INTERESTING
  • No related posts

COMMENTS / View Comments

Extremely useful tip!! Thanks! I’ve never been able to selfupdate my macports install while behind my work proxy until now!

If you only want to do this occasionally (not edit your sudoers), just use this on the command line for selfupdate:

sudo env http_proxy=login:password@proxy.example.com:proxy_port env RSYNC_PROXY=login:password@proxy.example.com:proxy_port port selfupdate

or this for normal port installs:

sudo env http_proxy=login:password@proxy.example.com:proxy_port port install some_port

Selfupdate may not require setting the http_proxy. You may need additional settings depending on how your proxy handles ftp. This works for me.

Chris Leonello added these pithy words on Apr 13 09 at 13:52

Awesome. Thanks so much. I was getting tired of trying all the extra_env settings.

Emmett Keyser added these pithy words on Aug 19 09 at 23:33

Thank you.

jeffschwab added these pithy words on Mar 04 10 at 19:04

Another way:
edit /opt/local/etc/macports/macports.conf
at the bottom there are options to set all the proxy variables just for macports.

swidnikk added these pithy words on Mar 16 10 at 23:44

SPEAK / ADD YOUR COMMENT
Comments are moderated.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

blog comments powered by Disqus Return to Top

Macports through a proxy

FRESH / LATEST POSTS

FEATURED / BEST OF Alex's Blog

Macports through a proxy
Automatic Table Row Numbers in LaTeX
PhD Project
Random Links
Engineers tell us that in the future, all newspapers will be delivered electronically
About
Cutbacks everywhere
Best use of the term wiffle ball in a scientific context
Feynman, Wilkes and more
iPhone App List

FOLLOW / YOUR COMMENTS

TAG / CLOUD

academia apple Business cloud cognitive radio conference google Identity ieee internet iphone jaiku Java Leolaporte Linux mac mbp microsoft nanoblogging netvibes news noms2008 osx Personal policy pownce Professional Research rss science Scoble slashdot software tech technology television Travel trivia twitter uk university challenge web web2.0 Web Link yahoo