In this tutorial you will learn how to repair “Setting locale failed” message on a ubuntu/trusty32 Vagrant box. I will use 3 approaches in order to fix the problem:
1. Edit /etc/ssh/sshd_config and comment:
AcceptEnv LANG LC_*
2. Compile a list of locale definition files using
sudo locale-gen ro_RO.UTF-8
3. Creating set-locale.sh bash script:
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=”en_US.UTF-8″
LC_NUMERIC=”en_US.UTF-8″
LC_TIME=”en_US.UTF-8″
LC_COLLATE=”en_US.UTF-8″
LC_MONETARY=”en_US.UTF-8″
LC_MESSAGES=”en_US.UTF-8″
LC_PAPER=”en_US.UTF-8″
LC_NAME=”en_US.UTF-8″
LC_ADDRESS=”en_US.UTF-8″
LC_TELEPHONE=”en_US.UTF-8″
LC_MEASUREMENT=”en_US.UTF-8″
LC_IDENTIFICATION=”en_US.UTF-8″
LC_ALL=
and run it with:
source set-locale.sh
Code used during this tutorial:
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# Vagrant Repair "Setting locale failed" message on ubuntu/trusty32 cd ~/vagrant/ubuntu-trusty32/ vi Vagrantfile vi provision-shell/bootstrap.sh vagrant up --provider virtualbox vagrant ssh # perl: warning: Setting locale failed. # perl: warning: Please check that your locale settings: # LANGUAGE = (unset), # LC_ALL = (unset), # LC_PAPER = "ro_RO.UTF-8", # LC_ADDRESS = "ro_RO.UTF-8", # LC_MONETARY = "ro_RO.UTF-8", # LC_NUMERIC = "ro_RO.UTF-8", # LC_TELEPHONE = "ro_RO.UTF-8", # LC_IDENTIFICATION = "ro_RO.UTF-8", # LC_MEASUREMENT = "ro_RO.UTF-8", # LC_NAME = "ro_RO.UTF-8", # LANG = "en_US.UTF-8" # are supported and installed on your system. # perl: warning: Falling back to the standard locale ("C"). # locale: Cannot set LC_ALL to default locale: No such file or directory # /usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory # Reconfigure an already installed package sudo dpkg-reconfigure tzdata # Get locale-specific information # Run on both host and guest OS locale sudo vi /etc/ssh/sshd_config #AcceptEnv LANG LC_* sudo service ssh restart # Changes take effect only after a fresh login exit vagrant ssh # No warning shown sudo dpkg-reconfigure tzdata locale sudo vi /etc/ssh/sshd_config #AcceptEnv LANG LC_* sudo service ssh restart exit vagrant ssh # Show warnings again sudo dpkg-reconfigure tzdata # Compile a list of locale definition files sudo locale-gen ro_RO.UTF-8 # No warning shown # Package configuration sudo dpkg-reconfigure tzdata # Default locale settings sudo vi /etc/default/locale LANG="ro_RO.UTF-8" exit vagrant ssh # Configurația pachetului sudo dpkg-reconfigure tzdata vagrant destroy -f vagrant up --provider virtualbox # Useful on a provision script when you can't restart SSH followed by a fresh login vi ~/set-locale.sh # Execute the script commands in the current shell environment source ~/set-locale.sh # Useful links https://www.liviubalan.com/fix-ssh-locale-environment-problems-on-ubuntu-server http://askubuntu.com/questions/53177/bash-script-to-set-environment-variables-not-working |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#!/bin/bash LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL= |
Useful links:
https://www.liviubalan.com/fix-ssh-locale-environment-problems-on-ubuntu-server
http://askubuntu.com/questions/53177/bash-script-to-set-environment-variables-not-working
https://www.liviubalan.com/ubuntu-server-locales