When you get errors with running commands on your Raspberry Pi like “warning: Setting locale failed.” you can fix this by updating the locale file in the OS. You can do this by typing:
pi@raspberrypi ~ $sudo nano /etc/default/locale
on your Raspberry Pi command line or in your Terminal window from your Mac when connected to the Raspberry Pi.
Next you have to change the following lines within the editor that just opened:
LANG = (unset), LC_ALL = (unset), LANG = en_GB.UTF-8
and change this into
LANG = en_GB.UTF-8, LC_ALL = en_GB.UTF-8, LANG = en_GB.UTF-8
Now you’ve edited the locale file and you need to save the file. You do this by exiting the nano environment by using the shortcut “CTRL + x”. And press “Yes” to save.