Can’t open crontab

cron

I tried running crontab on my Mac for the first time and got the following:

$ crontab -e
crontab: no crontab for User - using an empty one
crontab: subl -w: No such file or directory
crontab: "subl -w" exited with status 1

I've never used crontab on my Mac and have no idea why it's trying to reach the sublime command line tool.

However, if I type subl -w into my console, sublime opens right up.

What's going on here?

Best Answer

This is a known problem with crontab and the EDITOR variable which you must have set to subl -w. To quote from the man page of bbedit:

Some tools (notably crontab), will not work correctly if your EDITOR variable 
consists of multiple terms. You can work around this by creating a simple shell 
script that calls bbedit -w, then using the shell script as your EDITOR. e.g.:

                #!/bin/sh
                bbedit -w "$@"

Of course, for Sublime Text you can change bbedit to subl in that script.