TL;DR;
setting $VISUAL
to /usr/bin/nano
makes the crontab -e
working for me!
Details
I ran in a similar issue on Monterey in zsh
but it was due to SublimeText
was configured as default editor:
echo $EDITOR
# output:
subl -w
When trying to edit the crontab of either user or root I got:
crontab -e # or
sudo crontab -e
# output
crontab: subl -w: No such file or directory
crontab: "subl -w" exited with status 1
Neither solutions from other suggestions worked:
- to change the
$VISUAL
editor variable to subl -w
- omitting the
-w
or
- editing the sudoers file via
visudo
helped not (to get visudo
to work, I had to set both $EDITOR
and $VISUAL
to nothing)
export EDITOR=""
export VISUAL=""
actually the suggested line was already present!
Defaults env_keep += "EDITOR VISUAL"
Possible low level shell path issue
At the end it turns out to be related to the regular $PATH is not to be accessible by the crontab
command. Even symlinks seemed not to work until I set the $VISUAL setting different from $EDITOR to /usr/bin/nano
. Then it started working using nano
with an explicit absolute path.
export VISUAL=/usr/bin/nano
Standard $EDITOR
Setting can be preserved
For crontab
usage it is irrelevant if $EDITOR
is set to nothing
or subl -w
, both are suitable!
IMPORTANT:
To make these changes permanent you have to put the export lines in your terminal startup file ( ~/.zshrc
or ``~/.profile depending on your setup)
Make sure you granted Full Disk Access
to crontab
and cron
in ``System Preferences```
Giving cron full disk access
If you are using [[macOS]] [[Catalina]] (or higher) you will also need to give the cron service
Full Disk Access.
- Go to the System Preferences and select Security & Privacy.
- In the left-hand column, select
Full Disk Access
, click thepadlock icon
, enter your password and click on the plus icon
for a file browser to appear.
- When the file browser appears, press
⌘ ⇧ G
to open the go to folder dialog
and type: /usr/sbin/cron
- Press
Go
to close the dialog and confirm that cron
appears in the list of apps that have full disk access in the Security & Privacy
window.
- Repeat with
/usr/bin/crontab