Mountain Lion and Rails development

Mac — squarism @ 7:52 pm


If you do development on a Mac, you might be considering upgrading to Mountain Lion because of speed improvements and you greatly desire a notes application with a skeuomorphic leather-bound notes application. :)

I was afraid to take the plunge early so last night I did a test upgrade on a Mac that is not my main dev one.

Get Xcode working
First of all, you can follow this gist:

They have you go to developer.apple.com to get Xcode 4.4 but you can also use the App Store’s upgrade button. Step #2 explicitly has you download the command line tools for Xcode but you can also use the Xcode 4.4 command line tools for 10.8 from the developer site. Both of these downloads are under 300mb.

Also, please note that there are many, many forks of that gist above. Some just include extra screenshots in case you aren’t familiar with Xcode but some follow very different steps. I pretty much followed just the ‘master’ fork of that gist to get Xcode working.

Fix Bundler
But then I did a `bundle` in a rails project that uses a native lib (eventmachine) and bundle puked because it couldn’t find gcc-4.2 in my path. It looked something like this:

Because Xcode 4.4 is LLVM based. So I followed the rest of the ruby specifc bits on thoughtbot. Specifically, the “Fix Homebrew + install GCC” section. The rest of the blog post is handled by the gist above.

Things seem to work but my test box is not my day-to-day dev box. I thought I’d share so you guys know that it’s not an automatic upgrade for devs. Definitely do the upgrade over the weekend or with some downtime.

Brew upgrade
You might run a brew update && brew upgrade regularly to keep your libraries and apps up to date but it installs multiple versions. So you run a brew cleanup to remove old versions. Well beware of some changes I’ve seen (I don’t know the timeframe). Conf files might be in the old versions. For example, my mongod.conf was under /usr/local/Cellar/mongodb/#{old_version} but brew cleanup removed that directory. Luckily, I just had the default config file in there. The new location is /usr/local/etc/mongod.conf (as it should be). I’ve seen this in other packages too. Some packages have changed over the years so just take a look at your filesystem paths and config file locations. If you reinstall brews for the Mountain Lion upgrade or do a brew cleanup make sure files you want to save won’t be lost when doing a `brew remove` or `brew cleanup`.

Also, the launchagent plists have changed.
ls ~/Library/LaunchAgents
homebrew.mxcl.mysql.plist (the file used to be called org.mysql.plist)

So when upgrading, homebrew will tell you to launchctl unload the old one. But homebrew won’t tell you that the name has changed. Just something else to watch out for. If you delete the old file before launchctl unloading, you’ll have a few extra steps to do for forcefully unload it. Not a big deal. Just follow homebrew’s instructions but also realize that they won’t tell you that the filename has changed.

Watchr filesystem events not firing

Mac,Ruby — squarism @ 10:30 pm

I wanted to use a ruby environment inside a Ubuntu VM but still be able to edit text files in Textmate. So I shared out my project folder and fired up a watchr script I made. Unfortunately, it didn’t work at all.

I tried a few different libs, including rev, rb-inotify, rb-fsevents (which turned out to be mac only) but nothing was firing when I’d save a file. I thought maybe rev or watchr was broken in 1.9 but that was not the case. The problem is the vmware shared folders. When you do a write, modify or whatever, it doesn’t fire the same hooks as a local event does:

Modify File -> Textmate Save -> project/foo.txt (does not fire in watchr)
Modify File -> Vi Save in VM -> project/foo.txt (watchr fires)

And it wasn’t just watchr (as I said), every ruby library was seeing the same thing. So I gave up on the shared folders through VMware and just installed netatalk.

sudo aptitude install netatalk

I can edit files in Textmate this way and watchr works as expected. So why is this important? Because a tight REPL is important. And watchr / wtchr makes the tight loop happen. This is also probably going to happen if you use autotest in a project with lib/* test/* too.

Pretty specific but I hope it helps someone.

Reconnect a Mac mouse without a mouse

Mac — squarism @ 7:23 pm

So you’ve replaced the batteries, restarted your mouse or whatever. You have a bluetooth mouse that you need to reconnect or re-pair but you don’t have a mouse to get to the bluetooth icon in the notification area or status bar location.

Here what you do:

  1. Command Key + Shift + / – gets you into the help area in any menu
  2. Right arrow – gets you to the Apple menu
  3. Down arrow until System Preferences
  4. Enter – opens System Preferences
  5. Type mouse – in the search box and hit enter will open the mouse pane
  6. Hit enter at the “no mouse found” screen – this will pair your mouse if it’s powered on and trying to pair

Problem solved. Leave a comment if it works or a similar problem but different solution worked for you. If you can’t click in the comment box, just scream really loud towards my email address. :)

Nmap won’t compile in homebrew solution

Development,Mac,Unix — squarism @ 1:11 am

I recently moved my Mac Pro dev box to homebrew from macports. Doing the mysql move (the lazy way — moving the data directory) was easy enough but doing a massive `brew install` of a bunch of packages didn’t work when I got to nmap (the network port scanner).

Specifically the linker error (maybe the linker … looks to a stacktrace to a Ruby and Java guy) was this:

I love the little URL for more help at the bottom, unfortunately a redirect killed the help. The correct URL is here. Maybe an anchor tag in the wrong place on the URL, who knows. Anyway, I posted a note on the issue site as well, I got around the issue by doing this first:
brew install lua

Then just install nmap like before:
brew install nmap

Worked for me.

Macports upgrade breaks ImageMagick

Mac,Ruby — squarism @ 1:55 pm

A blind upgrade of all macports packages broke my ruby project because it uses imagemagick.


dlopen(/opt/local/lib/ruby/gems/1.8/gems/rmagick-2.13.1/lib/RMagick2.bundle, 9): Library not loaded: /opt/local/lib/libMagickCore.3.dylib
Referenced from: /opt/local/lib/ruby/gems/1.8/gems/rmagick-2.13.1/lib/RMagick2.bundle
Reason: image not found - /opt/local/lib/ruby/gems/1.8/gems/rmagick-2.13.1/lib/RMagick2.bundle

Massive hack incoming:

cd /opt/local/lib
sudo ln -s libMagickCore.4.dylib libMagickCore.3.dylib

There should be a better solution but I can’t find one until macports gets it’s goddamn *bEEp* straight. I swear to deity, every time I do a sudo port upgrade outdated, something breaks. I know it’s not macports fault but the nature of native ruby gem extensions but I’m just going to avoid upgrading.

Something else to consider is my recent switch to homebrew. I haven’t made the switch on all my boxes and the ImageMagick problem isn’t related to the package manager. I do prefer brew’s command structure. Moving MySQL wasn’t insanely difficult but I did cheat by just doing a stupid copy of the MySQL data files.

iPhone Developer Activation Problem

Mac,ObjC — squarism @ 5:58 pm


I went to renew my membership on my iPhone developer account and although the membership is $99/year, my expiration date was only extended out for 3 months. I opened a ticket and it took about a month or two to get this thing resolved. I had to send screenshots, steps and evidence that I was doing the right thing (ok, fine, tier 1 support). Eventually I got a person that had a trick up their sleeve but didn’t quite get it right. I’m blogging this in case this is happening to someone else.

First, the symptoms. Let’s say your dev account is about to expire in January 2010. You want to renew for another year. You add a year subscription to your cart, pay for it. You’d expect your new expire date to be Jan-2011. But in your profile and in the “thanks for ordering” activation page it says March 2010 or something else wrong. Support send me activation links basically to the same page that wouldn’t activate any differently. Each time I checked out, it would say March 2010.

The trick was to click on renew membership (as if paying again), click the checkbox to select which membership you want to buy ($99 year) and hit continue. Now you’re on a “Review your purchase” page. Click continue here. Finally, it says “Proceed to your country’s Apple Online Store to purchase” and has an add to cart button. Stop here.

Click the following link: http://developer.apple.com/iphone/enroll/activate.action. It should bring you to a page with a single textbox for your activation code (the one you’ve been trying to use all along). Put this in and hit continue. Your expire date should be correct now. If not, try using a link formatted like this:
http://developer.apple.com/iphone/enroll/activate.action?activationCode=YOURCODEHERE

Seems like they have some bug in the dev store. Please comment if this helped you so it’s documented.

RMagic, ImageMagick, Snow Leopard and Ruby 1.9

Mac,Ruby — squarism @ 10:32 pm

I ran into a problem that kept me busy over the weekend. It seems that rmagick (which is requires for the awesome sparklines project will compile and run on Snow Leopard, however it has a critical bug when trying to use it. The script/server process will crash with a “Trace/BPT trap” error. The logs won’t say anything and the hell if anything is going to appear on the browser. WTF.

Here’s my stack on my Mac: (do not use this stack, this is just for informational purposes only)

  • ruby19 installed via macports: sudo install ruby19
  • regular rubygems installed
  • ImageMagick 6.6.0-0 installed via macports
  • A bunch of github gems installed but not firing on the controller method that crashes

So I started over on a CentOS 5.4 VM just to try out my stack and it worked. Except, I used ruby 1.8.7 compiled via source. It’s a really lengthy process and it’ll be part of my README if I ever get this project done. On CentOS you have to compile and install ImageMagick yourself because yum has a really old version. There’s a ton of devel dependencies too. If anyone needs the instructions, leave a comment and I’ll copy/paste from my README.

So I suspected that ruby 1.9 was causing problems my mac laptop and that turned out to be true. I did a sudo port uninstall ruby19 and then a sudo port install ruby. I had to reinstall all the gems again but it wasn’t too bad. If port gives you a ln error, just exit your shell and open a new one.

So RMagick, ImageMagick and ruby 1.9 do not play together.

Growl Network Notifications Not Working

Mac — squarism @ 9:13 pm

Growl’s network notifications weren’t working. Either sending or receiving. I had two machines that had growl cleanly installed and my main machine that’s had many versions installed over the years. It was my main box with a dirty growl history that was having problems.

I found a post on cocoaforge that helped a lot. First, I ran the uninstall applescript (I always keep uninstallers in ~/Uninstallers but you can find it in the Growl.dmg). That didn’t really work, it gave me an Apple Script time out. So I removed everything manually. I deleted the pref pane from SysPrefs by right-clicking on Growl and selecting remove.

growl_remove

After that was done I removed the preferences file from ~/Library/Preferences and also a folder under ~/Library/Application Support called Growl (has two subfolders called Tickets and Plugins). I emptied trash. Reinstalled Growl 1.2 (latest). I didn’t restart. I re-setup the network bit of Growl on this page:

growl_network

Notifications started working. Now all my boxes are notified when something cool happens. Weee!

Scroll Lock Button on OSX

Mac — squarism @ 4:31 pm

Here’s an esoteric fix for something I wanted to do. In a certain game, right click will move the camera. For some reason, when hosting synergy on the Mac (as the server) and connecting a Windows client, the right clicking gets whacked. It works fine the other way (don’t ask me).

So I want to hit scroll lock to lock the screen so that mouse-looking works. Except there’s no scroll lock button on a Mac keyboard! Doh. But I find a solution:


keystroke(f13) = lockCursorToScreen(toggle)

Found on mattcutts.com, this is the option I need. I use SynergyKM, which is a Mac-ified app to control synergy. It doesn’t use the conf file of synergy but instead uses a .plist property file. So I edited it to look like this:

Synergy Scrolllock

And viola, roll over to the XP box from Mac, hit F13 and mouse look works in WoW (or probably any other drag-tracking app).

Synergy2 mouse centering

Development,Mac — squarism @ 9:29 pm

Synergy is a great tool for sharing multiple screens (reverse KVM) but for some reason lately I’ve noticed that if I’m physically on the center screen, then the mouse recenters occasionally. It’s pretty annoying.

I turned on debug log and looked in ~/Library/Logs/synergyd.log. I found this:

2007-10-04 22:12:11.894 Synergyd[337] DEBUG: dropped bogus motion -840,-526

I searched sourceforge for that string and found code that essentially centers the mouse when it detects motion on the primary screen. There doesn’t seem to be an option to control the behavior, so short of me making a patch, I don’t see a solution.

UPDATE: I found a workaround, simply move your mouse over to the display that it being buggy and the if() condition doesn’t fire off. So in my case, my mac connects to my PC’s keyboard and mouse. I move the PC’s mouse over to the Mac screen and the Mac stops acting weird (the centering problem).

Next Page »
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2013 SQUARISM | powered by WordPress with Barecity