Dheeraj Kumar

Ruby, Golang, Scala, Javascript

A Help Message Which Actually Is Helpful

| Comments

One fine morning last week, I booted my Macbook Pro I had shut down the previous night. The sun was young in the sky, birds chirped and cawed atop freshly-green trees, whose canopies cast their shade on a plethora of beings – from a baby squirrel looking for its nuts, to a driver in a Camry, screaming his off at a jaywalker.

All in all, a great day to code.

…or so I thought.

My Rails app didn’t boot, and this was the error I got:

1
Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2 "No such file or directory")

It wasn’t expected, as launchd was supposed to start the database server on boot. “That’s not so bad”, I thought, as I typed the familiar line into zsh:

1
2
3
4
5
$ sudo mysql.server start
/usr/local/Cellar/mariadb/10.0.10/bin/my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 "No such file or directory")
Fatal error in defaults handling. Program aborted
Starting MySQL
...................................^C

That’s just way too many dots, and deserved a CTRL+C.

…and what was that error? I didn’t remember doing anything to blow up my MariaDB installation.

I sighed, rolled up my sleeves, and started debugging.

Actually, the sleeves were already rolled up. I just sighed and started debugging.

My first stop was to call the doctor:

1
2
3
4
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Nothing. Hmm. Next, I looked for more info about the package:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$ brew info mariadb
mariadb: stable 10.0.13 (bottled)
http://mariadb.org/
Conflicts with: mysql, mysql-cluster, mysql-connector-c, percona-server
/usr/local/Cellar/mariadb/10.0.10 (525 files, 125M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/mariadb.rb
==> Dependencies
Build: cmake ✘
==> Options
--enable-local-infile
  Build with local infile loading support
--universal
  Build a universal binary
--with-archive-storage-engine
  Compile with the ARCHIVE storage engine enabled
--with-bench
  Keep benchmark app when installing
--with-blackhole-storage-engine
  Compile with the BLACKHOLE storage engine enabled
--with-embedded
  Build the embedded server
--with-libedit
  Compile with editline wrapper instead of readline
--with-tests
  Keep test when installing
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.

To connect:
    mysql -uroot

To reload mariadb after an upgrade:
    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
Or, if you don't want/need launchctl, you can just run:
    mysql.server start

That’s a lot of info, but not helpful to fix the issue at hand.

I knew that there are usually more messages not displayed here, so I ran:

1
2
3
4
5
6
7
8
9
10
11
12
$ brew postinstall mariadb
==> /usr/local/Cellar/mariadb/10.0.13/bin/mysql_install_db --verbose --user=dheeraj --basedir=/usr/local/Cellar/mariadb
--user=dheeraj
--basedir=/usr/local/Cellar/mariadb/10.0.13
--datadir=/usr/local/var/mysql
--tmpdir=/tmp


READ THIS: https://github.com/Homebrew/homebrew/wiki/troubleshooting

These open issues may also help:
mariadb: missing /usr/local/etc/my.cnf.d, removed by brew prune (https://github.com/Homebrew/homebrew/issues/31760)

Hello there! That’s my exact error! The issue on GitHub is very helpful, it reminded me that I ran brew prune the previous night, which apparently removed a directory MariaDB requires. It also had a simple fix, which I tried:

1
2
3
4
$ mkdir /usr/local/etc/my.cnf.d
$ sudo mysql.server start
Starting MySQL
. SUCCESS!

And the universe was restored to order, again.

My takeaway from this whole incident was that, all it took to fix my problem was a strategically placed help message. Homebrew needn’t have cared about it, but the fact they did is what differentiates great software from good software.

User experience is not just about GUIs, flat design and Fitts’s law. It’s about being easy to use, and being helpful to the user when they need it the most.

Thanks, Homebrew, for nailing it.

Comments