Head Banging weird Mountain Lion Network Issues

Okay, so the recent Mountain Lion Install went fairly smoothly with only a nfew hiccups. That was until I tried to update my blog post …

At first, everything worked as expected, but when I tried to update a longer post, the POST just timed out. I wan't too upset, it's my own bloging engine, so I just assumed my code would at fault. Later, I noticed a few other wweb pages weren't working either, and not samll sites, big ones, like facebook.com and apple.com, even apples disscussions.apple.com wouldn't load, and Dropbox had stopped syncing. Something was very wrong. Anyway, I was at work and couldn't spend all day fixing my MacBook, so I just switched to my iMac, still running Lion, everything was fine. Obviously a bug in the initial version of the OS.

Later at home, I fired up my MacBook, to try and resolve the problem. Everything worked fine. All of my problems at work just didn't manifest on my home network.

Next day, back at work, and the problems were all back, execectly the same. Now I had a very Mountain Lion specific bug only on the network at work, without any clue as to what was going on.

The Solution

A bit searching later, I stumbled across this post by Matt, from 2011, about imporving network performance by changing the Hardware MTU setting. His post does a great job explaing what the MTU does and how it effects netowrk traffic. So, I gave it a go to see if it would help.

The basic test to try is to send a TCP ping packet to a server, in my case the aunty beeb. The import part is setting the size, in bytes, of the packet and not allowing the payload to be spread of mutliple packets. This gives you your network MTU.

ping -c 2 -D -s 1464 bbc.co.uk

If the command Timesout, try lowering the -s. If the command pings back correctly, try upping the -s flag. The tick is to use the figure + 28 in your network settings.

Now, even though Mountain Lion shoudl be able to autodetect this, apparenetly its not as good as Lion was. By changing my MTU (in Preferences->Network->Advanced->Hardware), from 1500, to 1490, everything works fine. In fact, its better than fine, it's now pretty quick!

Now, i'm hoping this is only a temporary fix, and that the first service update to Mountain Lion fixes the autodetection, as i really dont want to have to check the MTU of every network I join!

 

Setting up a Ruby/Rails Environment in Mountain Lion

So, I've just backed up about 500Gb of stuff on Laptop, formatted the HD, and installed Mountain Lion from the Recovery partition, all fairly simple, a bit time consuming , but I like to have a completely fresh system for new OS installs, and overtime I've been streamlining my approach.

First off, Xcode

Make sure you've got the latest Xcode, currently 4.4, then after that installs, you'll need to enable command line tools, Xcode -> Preferences -> Downloads

That should be all of Xcode setup and working for development, however, if you plan on using ruby 1.9.2 or earlier, you'll also need to install gcc-4.2 separately (via HomeBrew)

Homebrew

[HomeBrew][http://mxcl.github.com/homebrew] has become my standard package manager on OS X, It's pretty simple to setup, and works well out of the box

/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

GCC

As Xcode no longer installs gcc, you'll have to install it manually before any ruby before 1.9.3. First you need to enable the homebrew-dupes repository, which gives you access to builds of Apples Open Source tools.

brew tap homebrew/dupes
brew install apple-gcc42

Databases

For now, we'll just setup MySql and Postgres as SQLite is included in OS X.

MySql is easy:

brew install mysql

Postgres is a bit more troublesome, and there appears to be a bug at the moment with Mountain Lion, which the current 'workaround' is to install without ossp-uuid. This works for me at the moment, but I'll be checking to see when this gets fixed.

Both databases will still require a bit more setting up, the commands to run will be output to the screen after you install them.

brew install postgresql --without-ossp-uuid

There will probably be plenty of other tools you'll need to install, but for me, the last big one is ImageMagick.

brew install imagemagick

This will prompt you to install Java (a necessary evil unfortunately).

RVM

All my rubies for development our managed by RVM, Very useful tool, and very simple to install.

curl -L https://get.rvm.io | bash -s stable --ruby

So, that should be enough to get a decent working development environment for Ruby/Rails projects, obviously you'll need to install rails and other project dependencies with bundler, but hopefully you be pretty used to those commands.

XQuarts

[XQuarts][http://xquartz.macosforge.org/landing] is needed if you plan on doing anything X11 related, just down and run the installer

Installing old Rubies with RVM

So, they setup earlier works fine for installing new rubies (i.e., 1.9.3), but it doesn't work so good for 1.8.7 and its bretheren. Now, I know these are old, and and you really shouldn't be using them anymore, but I still work on some old projects that require them. A simple change to your login environment should do the trick:

# in ~/.bash_profile or ~/.zshrc
export CC=/usr/local/bin/gcc-4.2
export CPPFLAGS=-I/opt/X11/include