Running Karma and Chrome under tmux on OSX.
If you’re building Angular.JS apps, you’ll probably be using the excellent Karma test runner. I’ve been running into some troubles getting Google Chrome to work when using tmux on OSX. Here’s how to fix it.
The problem
I’m a fossil, I don’t use fancy new IDEs. My tools of trade, which have served me well for years now are tmux and vim. Tmux is like screen, but more powerful. It allows me to split my terminal into panes and have bash next to vim. Awesome.
Things go wrong when you start using the Karma test runner with Google Chrome.
You’ll be greeted by this guy:
The solution
Chrome crashes on any page, so this really doesn’t have anything to do with Karma (it just manifests itself there, because it launches a completely new Chrome instance). Turns out the daemon model of tmux is the problem here: tmux runs detached from the GUI, which means Chrome can’t find a screen to paint on.
There’s an easy fix!
- Get Homebrew, if you don’t already have it.
brew install reattach-to-user-namespace
- Add the following line to your .tmux.conf file:
set-option -g default-command "reattach-to-user-namespace -l bash"
Start a new tmux server and everything should work again.
Credit to http://robots.thoughtbot.com/post/19398560514/how-to-copy-and-paste-with-tmux-on-mac-os-x.