Monthly Archives: August 2011

Adding a SATA II SSD to an old Macbook & Creating a Snow Leopard bootable USB drive

The hard-disk in my sisters Macbook laptop finally emitted it’s last death rattle and shuffled off to silicon heaven so I found myself needing to install Snow Leopard (it’s too old for Lion) on a new disk drive. This was complicated by two factors.

  1. The Macbook is old, it only has a SATA (not SATA II) disk controller.
  2. The DVD drive had also died a long time ago.

I had read that SATA II disks sometimes worked on SATA controllers, but also a number of reports that the Macbook didn’t recognise some SATA II disks. I took a risk and bought an OCZ Vertex 2 60GB SSD from Amazon. So far the Macbook has recognised it. This was the easy bit.

Next I needed to install Snow Leopard. This was going to be harder (I thought) because the DVD drive in the machine was broken. I checked a bunch of tutorials on the Internet on how to create a Snow Leopard install USB drive but most assumed the USB drive would be created on Snow Leopard itself (I’m using Lion) and included a fairly large number of steps.

I gave up on these guides and decided to do it freestyle and it turned out to be incredibly simple. Here’s how in-case someone ever needs to do this in the future.

  1. First, I inserted my Snow Leopard DVD into my Mac and the USB drive into a USB port.
  2. Next I formatted the USB key as Mac OS Extended (Journaled) using Disk Utility ensuring it had a Master Boot Record.
  3. Finally I restored the Snow Leopard DVD to the USB key again using Disk Utility.

That was it. I tried it out on my sisters Macbook and it booted from it just fine and is now installing Snow Leopard on the OCZ SSD.

Fixing the Gemfile not found (Bundler::GemfileNotFound) error

I was working on an app (bundler, unicorn, Rails3) that had a strange deploy issue. Five deploys (using capistrano) after our unicorn processes had started unicorn would fail to restart, this is the capistrano output:

* executing `deploy:restart'
* executing `unicorn:restart'
* executing "cd /u/apps/dash/current && unicornctl restart"
servers: ["stats-01"]
[stats-01] executing command
** [out :: stats-01] Restarting pid 15160...
** [out :: stats-01] PID 15160 has not changed, so the deploy may have failed. Check the unicorn log for issues.

I checked the unicorn log for details:

I, [2011-08-02T15:59:32.498371 #11790] INFO -- : executing ["/u/apps/dash/shared/bundle/ruby/1.9.1/bin/unicorn", "/u/apps/dash/current/config.ru", "-Dc", "/u/apps/dash/current/config/unicorn.conf.rb", "-E", "production"] (in /u/apps/dash/releases/20110802155921)
/opt/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/definition.rb:14:in `build': /u/apps/dash/releases/20110802152815/Gemfile not found (Bundler::GemfileNotFound)
from /opt/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler.rb:136:in `definition'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler.rb:124:in `load'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler.rb:107:in `setup'
from /opt/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/setup.rb:17:in `'
from :29:in `require'
from :29:in `require'
E, [2011-08-02T15:59:32.682270 #11225] ERROR -- : reaped # exec()-ed

Sure enough there’s the exception, “Gemfile not found (Bundler::GemfileNotFound)“, and the file referenced (/u/apps/dash/releases/20110802152815/Gemfile) didn’t exist. The directory that was being looked in (20110802152815) was from a previous deploy and had been rotated off the filesystem. We keep five historical deploys so that explained why the problem only happened five deploys after a full unicorn restart.

I suspected an environment variable was getting set somewhere, and never updated, so I added some debugging to our unicorn.conf.rb file:

ENV.each{ |k, v| puts "#{k}:tt#{v}" }

I then restarted the unicorns fully and tailed the unicorn log file while deploying the app. Sure enough one of the environment variables stuck out:

BUNDLE_GEMFILE: /u/apps/dash/releases/20110802165726/Gemfile

I deployed again, it remained the same, still pointing to /u/apps/dash/releases/20110802165726/Gemfile. I continued to deploy until release 20110802165726 was rotated off the filesystem and up pops the error again. This looks like the problem.

I committed a change to our unicorn.conf.rb that set the BUNDLE_GEMFILE variable explicitly in the before_exec block:

before_exec do |server|
ENV['BUNDLE_GEMFILE'] = "/u/apps/dash/current/Gemfile"

end

Over 5 deploys later and the env var is still set to /u/apps/dash/current/Gemfile and there are no more errors. Let me know if you found this useful!

Notes

  • There may be other issues that cause errors of this type, this was just the solution that worked for us, YMMV.
  • There may be better places to set the environment variable other than the unicorn.conf.rb, I’m open to suggestions (we’re using bluepill, I may be able to set it there for intance).
Update: I’ve changed this on our systems so the environment variable is set in bluepill, it works the same.
Tagged , ,
Follow

Get every new post delivered to your Inbox.