2

I'm logging into a Mac laptop from a Linux laptop over ssh - so I have an ssh daemon on the Mac side, and I'm using the /usr/bin/ssh client on the Linux side.

I consistently get:

-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8): No such file or directory

Logging in from the mac to the same mac, does not give the warning; it's only when I log in from a Linux system that I get that warning.

Putting the following in my Mac's .bash_profile does not help:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Running localedef on the Mac gives the following error:

bash-5.1# /usr/bin/localedef -i en_US -f UTF-8 en_US.UTF-8
Can't open UTF-8: No such file or directory

But I do appear to have an en_US.UTF-8 locale on the Mac:

bash-5.1# pwd
/usr/share/locale
bash-5.1# ls -ld en_US.UTF-8
drwxr-xr-x  8 root  wheel  256 Jan  1  2020 en_US.UTF-8

What do I need to do to log into the Mac from Linux without a warning and get my preferred locale set?

I'm using homebrew's /usr/local/bin/bash if that matters.

Thanks!

12
  • But what locale is the Mac using? Apr 26, 2021 at 20:07
  • Linux recognizes both UTF-8 and utf8, but macOS only recognizes the UTF-8 spelling. I can't figure out how to teach it about an alias. On Big Sur, there's a file /usr/share/locale/locale.alias, but it's protected by SIP and I don't know if there's another location where you can put the same information. Apr 26, 2021 at 20:08
  • If you rewrite the value in your .bash_profile, your locale choice will take effect in interactive sessions, but you'll still have the error message when bash starts (assuming the Homebrew bash is your login shell). Apr 26, 2021 at 20:10
  • @MarcWilson echo $LC_ALL gives en_US.UTF-8
    – dstromberg
    Apr 26, 2021 at 21:00
  • @Gilles'SO-stopbeingevil' Yes, Homebrew bash is my login shell, and it appears in /etc/shells.
    – dstromberg
    Apr 26, 2021 at 21:02

1 Answer 1

1

I decided to:

LC_ALL=C ssh remote-mac.example.com

And the Mac was happy.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .