Changing locale in Ubuntu 15.04 VPS is not being saved - linux

I just bought a VPS and I'm playing it it using SSH.
After a few software packages installations I saw that I had a problem with locales (I need to have en_US.UTF-8 but I have Latin1. I googled it but even after I think I've changed locales then they keep returning to the original ones and I still get problems with software installation.
So, I get:
root#myname:~# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=pt_PT.UTF-8
LANGUAGE=
LC_CTYPE="pt_PT.UTF-8"
LC_NUMERIC="pt_PT.UTF-8"
LC_TIME="pt_PT.UTF-8"
LC_COLLATE="pt_PT.UTF-8"
LC_MONETARY="pt_PT.UTF-8"
LC_MESSAGES="pt_PT.UTF-8"
LC_PAPER="pt_PT.UTF-8"
LC_NAME="pt_PT.UTF-8"
LC_ADDRESS="pt_PT.UTF-8"
LC_TELEPHONE="pt_PT.UTF-8"
LC_MEASUREMENT="pt_PT.UTF-8"
LC_IDENTIFICATION="pt_PT.UTF-8"
LC_ALL=
But before, I have done:
locale-gen en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US:en
export LS_ALL=en_US.UTF-8
So, I can I solve this forever?
PS: I'm doing all this using SSH.

That's because my locale in my local machine is set to Portuguese, which SSH forwards to and tries to use on the server, but the server does not have it installed.
I could have stopped forwarding the locale environment variable from my local machine to the server. To do that I would have commented the SendEnv LANG LC_* line in the local /etc/ssh/ssh_config file.
Instead I decided to:
1) Generate the locale - Generate the English locale on the server with sudo locale-gen en_US.UTF-8
2) Stop accepting locale environment variable from my local machine to the server. To do that I commented the AcceptEnv LANG LC_* line in the remote /etc/ssh/sshd_config file. Note that for this I had to install the nano package to edit the file (after sudo apt-get install nano I just did nano filename when I was in the file directory).
3) Set the server locale to English - by adding the following lines to my remote ~/.bashrc or ~/.profile files using nano filename again (don't forget they are hidden files inside your home directory so they won't appear in a simple ls search; you need to use ls -la command):
export LANGUAGE="en"
export LANG="C"
export LC_MESSAGES="C"
export LANG=en_US.UTF-8
export LANGUAGE=en_US:en
export LS_ALL=en_US.UTF-8
I also restarted the VM and before that I closed my SSH session and reenter to see if changes were working.

Related

Different GOPATH in bash terminal and in Goland IDE

I've changed my GOPATH and in order to make the change persistent I've added the following line in my .bashrc file:
export GOPATH=$HOME/workspaces/go_projects
After restart, when I run go env in the bash terminal I see the correct path, but when I check in the GoLand IDE terminal I still see the old path.
Any ideas?
I'm running on on ubuntu 18.04.
You need to check the GOPATH settings for GoLand IDE.
Goto Settings > Go > GOPATH and check the settings.
Below is the snippet for my system.
Make sure you have selected "Use GOPATH that's defined in system environment".

spark-shell, pyspark are not working properly

I've installed spark-2.3.0-bin-hadoop2.7 on Ubuntu and I don’t think it has some problem with the java path. When I run "spark-submit --version" or "spark-shell" or "pyspark" I get the following error:
/usr/local/spark-2.3.0-bin-hadoop2.7/bin/spark-class: line 71: /usr/lib/jvm/java-8-openjdk-amd-64/jre/bin/java: No such file or directory
It seems "/bin/java" is problematic, but I'm not sure where to change the configuration. The spark-class file has the following lines:
if [ -n "${JAVA_HOME}" ]; then
RUNNER="${JAVA_HOME}/bin/java
The /etc/environment is:
bash: /etc/environment: Permission denied
What I now have in gedit ~/.bashrc is:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd-64/jre
export PATH=$PATH:JAVA_HOME/bin
This is the current java setup that I have:
root#ubuntu:~# update-alternatives --config java There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Nothing to configure.
bashrc has the following:
export PATH=$PATH:/usr/share/scala-2.11.8/bin
export SPARK_HOME=/usr/local/spark-2.3.0-bin-hadoop2.7
export PATH=$PATH:$SPARK_HOME/bin
Suggest me:
What files I need to change and
how I need to change them?
Java Home
Your JAVA_HOME should be set to your JDK
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd-64/jre
should be
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd-64
Here is the Oracle doc on JAVA_HOME (which should apply to Open JDK as well)
https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/
Spark Environmental Variables
The JAVA_HOME should also be set in the $SPARK_HOME/conf/spark-env.sh
https://spark.apache.org/docs/latest/configuration.html#environment-variables
😊

How can I run a python-rq rqworker as an attached-daemon in UWSGI in python 3 without ASCII encoding errors?

I'm trying to run rqworker as an attached-daemon in UWSGI. To do this I add to the config.ini file:
attach-daemon = /path/to/rqworker
Then UWSGI tries to launch rqworker when it should but I get the following error in the logs:
RuntimeError: Click will abort further execution because Python 3 was
configured to use ASCII as encoding for the environment. Either switch
to Python 2 or consult http://click.pocoo.org/python3/ for mitigation
steps.
I can run rqworker fine from bash but the encoding seems to be not set correctly for the daemon.
From the linked page in that message:
You are dealing with an environment where Python 3 thinks you are
restricted to ASCII data. The solution to these problems is different
depending on which locale your computer is running in.
For instance, if you have a German Linux machine, you can fix the
problem by exporting the locale to de_DE.utf-8:
export LC_ALL=de_DE.utf-8 export LANG=de_DE.utf-8 If you are on a US
machine, en_US.utf-8 is the encoding of choice. On some newer Linux
systems, you could also try C.UTF-8 as the locale:
export LC_ALL=C.UTF-8 export LANG=C.UTF-8
To set the encoding in the UWSGI config.ini file you can use "env" to set environment variables and in turn the locale. On a US machine this configuration would work:
env = LC_ALL=en_US.utf-8
env = LANG=en_US.utf-8
attach-daemon = /path/to/rqworker
On other machines, various other encodings could be used.

gnome-terminal doesn't work maybe because of locale setting

I installed Antergos (easy version of Arch) with the Japanese environment.
But I wanted to chaned the language to English, so I reffer the wiki article then run some commands after uncomment #en_US.UTF-8 UTF-8 in /etc/locale.gen and edit /etc/locale.conf into following:
LANG=en_US.UTF-8
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=
The problem starts from here.
I restarted my computer and found that gnome-terminal doesn't work.
I substituted eshell on Emacs and run gnome-terminal command, then got error messages:
(process:1202): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Error calling StartServiceByName for org.gnome.Terminal: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.gnome.Terminal exited with status 8
The output of locale command is following:
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=ja_JP.utf8
LC_TIME=ja_JP.utf8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=ja_JP.utf8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=ja_JP.utf8
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT=ja_JP.utf8
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
What changes some part of locale setting into Japanese? Or other reasons which terminate gnome-terminal exist?
I have tried solutions sugestted here https://bbs.archlinux.org/viewtopic.php?id=180103 .
Thank you.
I had the same problem some time ago. I fixed my locale config running this command
sudo localedef -f UTF-8 -i en_US en_US.UTF-8
The meaning of status code 8 is documented on gnome's website here:
The environment that gnome-terminal-server is started with does not
correctly set the locale to a UTF-8 locale. Consult your
distribution's documentation on how to fix this. Note that is it not
relevant to check the locale settings from a different terminal (e.g.
xterm); what counts is the environment that the session dbus-daemon
passes to the processes it starts.
So you're right, this is probably due to locale settings. I don't quite understand all the details, but if I set ~/.xinitrc to exec gnome-session and then run startx, I get a similar error to yours.
However, if instead of running startx, I start the gdm display manager (via systemctl start gdm.service on Arch), I can spawn a gnome-terminal correctly. So if you're okay with using gdm, that may be a solution. Lightdm also works, though SLiM doesn't (from my experience).
In the past, I also had to install the vte3 package for gnome-terminal to work, so make sure that's installed as well. And FWIW, sudo gnome-terminal seems to always work.
Did you think to regenerate your locales after you had edited your /etc/locale.gen file ?
locale-gen
I think in your explanation you mixed the /etc/locale.gen and the /etc/locale.conf files. Be sure you edited the correct file with the correct values.
Ok this is how I solved it;
sudo locale-gen --purge --no-archive
Then; sudo update-initramfs -u
Nothing with locale worked for me. Once changed back the default python version (3.5 on ubuntu16), terminal worked just fine.

linux locale unset

I have a ARM based machine with ubuntu distro on it and it often feeds me with this while running various commands:
Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "pl_PL.UTF-8"
This is output of the locale command
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=pl_PL.UTF-8
LC_CTYPE="pl_PL.UTF-8"
LC_NUMERIC="pl_PL.UTF-8"
LC_TIME="pl_PL.UTF-8"
LC_COLLATE="pl_PL.UTF-8"
LC_MONETARY="pl_PL.UTF-8"
LC_MESSAGES="pl_PL.UTF-8"
LC_PAPER="pl_PL.UTF-8"
LC_NAME="pl_PL.UTF-8"
LC_ADDRESS="pl_PL.UTF-8"
LC_TELEPHONE="pl_PL.UTF-8"
LC_MEASUREMENT="pl_PL.UTF-8"
LC_IDENTIFICATION="pl_PL.UTF-8"
LC_ALL=
What should I do to stop it from popping now and then and configure it properly for the ąęśćźńół [important characters of mine]?
OK, I found it
In some ubuntu distros on non 32bit x86 architectures it is misconfigured.
I needed to
sudo apt-get install language-pack-pl
or
sudo apt-get install --reinstall language-pack-pl if already installed
pl is the language code. Change to Yours.
and then
cd /usr/lib/locale
sudo ln -s pl_PL.utf8 pl_PL
and it's fixed
Of course installing the needed locales (sudo dpkg-reconfigure locales) is the best option, if you can.
But I do disable them sometimes, like follows:
unset $(locale|cut -d= -f1)
Try:
sudo dpkg-reconfigure locales
And select locales which You want use.
Next select default and finish.

Resources