Error: ENOENT when installing Pow on macOS

I kept getting this error when installing pow on macOS. There are some old threads about it, with fixes for previous verisons of OSX prior to El Capitan, but for the most part it seems to be a solved bug.

philihp@sterling ~$ curl | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  9039  100  9039    0     0   8763      0  0:00:01  0:00:01 --:--:--  8767
*** Installing Pow 0.5.0...
*** Installing local configuration files...
*** Installing system configuration files as root...
Password: hunter2

/Users/philihp/Library/Application Support/Pow/Versions/0.5.0/lib/command.js:20
      throw err;
Error: ENOENT, open '/tmp/pow.98645.1466285627293.3185'

If you’re getting this error too, perhaps the solution will be similar to mine?

It turned out that I had at some point changed the default shell of my root user to /usr/local/bin/fish, then uninstalled fish, and never bothered to set it back. I guess this isn’t really a problem most of the time because not much should (hopefully) ever run as root, but it finally surfaced here when trying to install Pow.

My solution was the following:

  1. Enable the root user with dsenableroot
  2. If you try to sudo su, you will get something like su: /usr/local/bin/fish: No such file or directory
  3. Change root’s shell with sudo chsh -s /bin/sh
  4. Disable the root user with dsenableroot -d

Once I did this, installing worked as normal.

philihp@sterling ~$ curl | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  9039  100  9039    0     0  17142      0 --:--:-- --:--:-- --:--:-- 17151
*** Installing Pow 0.5.0...
*** Installing local configuration files...
*** Starting the Pow server...
*** Performing self-test...
*** Installed

For troubleshooting instructions, please see the Pow wiki:

To uninstall Pow, `curl | sh`

Class ‘foo’ has no initializers

Quick post. It’s been a while. I’m just starting out with Swift, and this error kept coming up for me, but the error message could be a little more descriptive. It means that you have a non-optional member variable that needs to be initialized somehow.

class Foo: NSObject {
  var bar: String

That block will fail, saying Class 'Foo' has no initalizers. It isn’t that you need an init custructor, it’s that other things will depend on bar being set, and Swift doesn’t know what value to give it. This can be fixed by making bar optional, and anything using bar will have to handle the case where it’s missing

class Foo: NSObject {
  var bar: String?

or by giving it an initial value, so anything using it will either get its value, or (in this case) an empty string

class Foo: NSObject {
  var bar: String = ""

Configure MySQL on AWS t2.micro Linux AMI

I moved my blog over to an AWS VM, because I get 12 months of a free t2.micro instance. Can’t beat free hosting for a year, right? And about $10/month after that, on my own private virtual machine. Assumed things were going well, but I came back a few weeks later to find everything had gone to hell. WordPress was not connecting to the database.

[ ~]$ sudo service mysqld start
Starting mysqld:                                           [FAILED]

In looking at my /var/log/mysqld.log file, I found

160120 21:49:58 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
160120 21:49:58 [Note] /usr/libexec/mysql55/mysqld (mysqld 5.5.46) starting as process 27540 ...
160120 21:49:58 [Note] Plugin 'FEDERATED' is disabled.
160120 21:49:58 InnoDB: The InnoDB memory heap is disabled
160120 21:49:58 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160120 21:49:58 InnoDB: Compressed tables use zlib 1.2.8
160120 21:49:58 InnoDB: Using Linux native AIO
160120 21:49:58 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
160120 21:49:58 InnoDB: Completed initialization of buffer pool
160120 21:49:58 InnoDB: Fatal error: cannot allocate memory for the buffer pool
160120 21:49:58 [ERROR] Plugin 'InnoDB' init function returned error.
160120 21:49:58 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
160120 21:49:58 [ERROR] Unknown/unsupported storage engine: InnoDB
160120 21:49:58 [ERROR] Aborting
160120 21:49:58 [Note] /usr/libexec/mysql55/mysqld: Shutdown complete

The important thing here is InnoDB: mmap(137363456 bytes) failed; errno 12.

It looks like it couldn’t allocate the memory, which makes sense because a t2.micro instance only has a gig of RAM. Ought to be enough for anyone, right? Not for MySQL! The way to fix this is to open up your /etc/my.cnf file, and add a param innodb_buffer_pool_size = 1M (something reasonable). If you haven’t made any other changes, it should look similar to this:

# Disabling symbolic-links is recommended to prevent assorted security risks
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in

innodb_buffer_pool_size = 1M


Now if you start MySQL back up, everything should be fine.

[ ~]$ sudo service mysqld start
Starting mysqld:                                           [  OK  ]

Using Java 8 Lambdas with Google Guava Caches

With Guava, you can define a simple in-memory cache with

import static java.util.concurrent.TimeUnit.DAYS;

Cache cache =
        .expireAfterAccess(7, DAYS)

With this you can use .put(K, V) to load values, and .getIfPresent(K), which returns null if the key isn’t present. Sometimes it’s more convenientĀ to use get(K key, Callable<? extends V> valueLoader), where the valueLoader is called on a cache miss, and populates the cache and gives you what a cache hit would have given you. The old Java 7 way of doing this was really ugly:

cache.get(key, new Callable() {
    public V call() {
        return calculatedValue(key);

Don’t write ugly code. With Java 8 Lambdas, just do this:

cache.get(key, () -> {

How to parameterize an RSpec shared context

I had a RSpec shared_context which was creating a FactoryGirl user mock and then logging in with it, and then running some shared examples for testing permissions on a generic user. I needed to modify it to accept a parameter of using a different user.

It originally looked like this:

RSpec.shared_context "auth" do
  let(:current_user) { FactoryGirl.create(:user) }

  before(:each) do
    allow(User).to receive(:find_by_id)
    allow(User).to receive(:find_by_id).with( { current_user }

  shared_context "logged in" do
    before(:each) do
      login_as current_user

In my spec files, it was included by doing this:

describe MyController do
  include_context 'auth'

  context "when logged in as a normal user" do
    include_context 'logged in'


However I needed MyController to override current_user and use an admin user instead. Rather conveniently, you can override a context by sending it a block.

describe MyController do
  include_context 'auth'

  context "when logged in as an admin" do
    include_context 'logged in' do
      let(:current_user) { FactoryGirl.create(:admin) }


This works because the let inside of the block given is called again, and the new block calls let(:current_user) again and overrides the original block and FactoryGirl.create(:user) is never called.

This is documented here, however they don’t really show that it can be used for making your shared_context parameterized. So I’m going to say the word parameterized a lot here, and hope that when I (or you!) google “How do I parameterize an RSpec shared_context?”, you find this post.

Weblabora, Sailing, and Portland

Hi friends. I’ve been learning a lot of things recently, but nothing cool enough to be worth an entire blog post of its own, so here they are.


I’ve been resurrecting Weblabora recently by abstracting out the game logic into a JAR and rewriting the front-end with more modern technology. The front-end is also open source on Github and will be hosted at Not much to see right now, but I am making slow and steady progress. The idea, this time, is to make it so that more games can be added relatively easily.

A JAR of the game library is published to Maven repositories is the first JAR I’ve published under the com.philihp group


Lately I’ve been learning how to sail. The other day in practicing man-over-board drills in a J/24 we spotted a watermelon floating in San Francisco Bay. We rescued it and ate it for lunch.



For the second half of 2015 I will be living in Portland, Oregon. That’s about all there is to say about that.

How to use JUnit4 Hamcrest Matchers

JUnit borrows matchers from a library called Hamcrest, which look a lot like RSpec matchers in Ruby. They can be tricky to write, but end up being much more readable for complex assertions. At its simplest case, we can turn this assertion



assertThat(board.isGameOver(), is(true));

It’s slightly wordier, but I think it reads in English a little better, and is capable of still-readable more-complex assertions. The is() function here isn’t from extending TestCase (JUnit 4 no longer needs this, that was a JUnit 3 thing). It’s actually a static import, although there seems to be conflicting information on the internet on what needs to be imported. I found these to work in most cases:

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

From what I can tell, JUnit pulled in some, but not all of the matchers from Hamcrest. There are still some useful matchers in Hamcrest, so I like to import them, and there aren’t any namespace collisions. It doesn’t add any additional lines to your POM since you can actually leave out the JUnit dependency and just import the Hamcrest library (since it itself depends on JUnit).


In the actual test that motivated this post, I had a really specific need to test that a method would return a list which contained at any index a POJO bean which had properties for settlement being an instance of a Village class and score being 42. I was able to express this as

          hasProperty("settlement", instanceOf(Village.class)),
          hasProperty("score", is(42)))));

New City, New Job, New Format

I have relocated to San Francisco, and I now work at Airbnb as a Software Engineer.

Unfortunately, this blog will probably not see many more SAS-related posts until I can get my hands on a license. It will probably see a lot of new blog posts with newer, freer technologies. I’m learning a lot of Ruby and Rails, so expect some cool stuff on that front.

Also, I’ll probably drop more F-bombs.

Using SUBSTR on the left of an assignment in SAS

This is a pretty cool feature, and as far as I know it’s unique to SAS and Perl. In SAS, you can have a substr to the left of an assignment.


This avoids potentially awkward situations like this:


The bounds don’t have to be static. Lets suppose we have a dataset with 1 row per letter, and we want to combine those letters into a word.

data have;
    input letter $1.;

My initial thought was to just retain and append each letter:

data want;
  length word $200;
  retain word;
  set have nobs=nobs;
  call cats(word,letter);
  if(nobs=_n_) then output;

However this breaks if one of the letters is a space, and SAS treats the space as null, so appending a space has no effect on the string. Instead of appending, just stick the letter where it’s supposed to be.

data want;
  length word $200;
  retain word ' ';
  set have nobs=nobs;
  substr(word,_n_,1) = letter;
  if(_n_==nobs) then output;

Installing SAS 9.4 on Ubuntu 14.04

Officially SAS does not support Ubuntu Linux as a platform, in spite of it being the most popular desktop distribution. It will run, but there are two things you need to do:

First, reconfigure Ubuntu not to use dash. The SAS Deployment Wizard will freeze when you first click “Next” during the install if you don’t do this.

sudo dpkg-reconfigure dash

That being done, you should be able to install SAS Foundation.

Second, SAS requires libjpeg to run. When you first run sas, you’ll get this error:

        MODULE: sasmotifsasvsub HyS SUBSYSTEM: 8 SLOT: 11 
ERROR: Could not load /usr/local/SASHome/SASFoundation/9.4/sasexe/sasmotif (35 images loaded) 
ERROR: cannot open shared object file: No such file or directory 
        MODULE: sasmotifsasvsub HyS SUBSYSTEM: 8 SLOT: 11

Install this by running this command:

sudo apt-get install libjpeg62

SAS should now run.

Additionally, while not common, but if you have SAS/Secure installed and want to pull files via https, you’ll need to point it at SSL CA certificates. You can kick off SAS with


Or just create a file ~/sasv9.cfg with that in it.

Update: This works on 13.10 and 14.04