Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snap-based apps wrongly gripe about locale, etc. #22

Open
eggert opened this issue Oct 3, 2022 · 6 comments
Open

snap-based apps wrongly gripe about locale, etc. #22

eggert opened this issue Oct 3, 2022 · 6 comments

Comments

@eggert
Copy link

eggert commented Oct 3, 2022

I am running Ubuntu 22.04.1 LTS on x86-64 with current patches. I am using snapd 1.60-0ubuntu1.

When I run the shell command "chromium --version" and attempt to debug the resulting situation a bit, I see the following. As you can see, I get a bogus diagnostic about the locale and about my .bashrc. My locale is fine, although evidently snap packages can't use it. My .bashrc is quite simple and has not changed in two decades (it's mode -r--r--r-- which is evidently what snap is complaining about, but that has always worked fine with Bash).

$ chromium --version
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
/bin/bash: /home/eggert/.bashrc: Permission denied
Chromium 105.0.5195.125 snap
$ LC_ALL=C chromium --version
/bin/bash: /home/eggert/.bashrc: Permission denied
Chromium 105.0.5195.125 snap
$ echo $SHELL
/bin/bash
$ env | grep -E '^LC_|LANG='
LANG=C
LC_ALL=en_US.utf8
$ locale
LANG=C
LANGUAGE=
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=en_US.utf8

I see similar problems with Firefox and with snap-store, so this is not just a Chromium issue:

$ firefox --version
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
/bin/bash: /home/eggert/.bashrc: Permission denied
Mozilla Firefox 105.0.1
$ snap-store --version
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
/bin/bash: /home/eggert/.bashrc: Permission denied
gnome-software 41.3-64-g512c0ffa8+

Once (just after a long idle period in my login session) it was even worse:

$ chromium --version
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/cups/doc-root /usr/share/cups/doc-root none bind,ro 0 0): cannot create directory "/usr/share/cups/doc-root": permission denied
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/gimp/2.0/help /usr/share/gimp/2.0/help none bind,ro 0 0): cannot create directory "/usr/share/gimp/2.0": permission denied
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/libreoffice/help /usr/share/libreoffice/help none bind,ro 0 0): cannot create directory "/usr/share/libreoffice/help": permission denied
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/xubuntu-docs /usr/share/xubuntu-docs none bind,ro 0 0): cannot open directory "/var/lib": permission denied
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
/bin/bash: /home/eggert/.bashrc: Permission denied
Chromium 105.0.5195.125 snap
$ chromium --version
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
/bin/bash: /home/eggert/.bashrc: Permission denied
Chromium 105.0.5195.125 snap
$ LC_ALL=C chromium --version
/bin/bash: /home/eggert/.bashrc: Permission denied
Chromium 105.0.5195.125 snap

I have filed Ubuntu Bug #1983399 and Bug #1959845 about the locale and .bashrc problems; they suggested that it was an upstream problem and that I file a bug with you. I just now observed the update.go issue and have not filed a bug report with Ubuntu about that.

@sergio-costas
Copy link
Contributor

sergio-costas commented Oct 19, 2022

Mmm... but why your LANG environment variable is "C" instead of "en_US.utf8?

In my system, "locale" returns

LANG=es_ES.UTF-8
LANGUAGE=es_ES:en_US:en
LC_CTYPE="es_ES.UTF-8"
LC_NUMERIC=es_ES.UTF-8
LC_TIME=es_ES.UTF-8
LC_COLLATE="es_ES.UTF-8"
LC_MONETARY=es_ES.UTF-8
LC_MESSAGES="es_ES.UTF-8"
LC_PAPER=es_ES.UTF-8
LC_NAME=es_ES.UTF-8
LC_ADDRESS=es_ES.UTF-8
LC_TELEPHONE=es_ES.UTF-8
LC_MEASUREMENT=es_ES.UTF-8
LC_IDENTIFICATION=es_ES.UTF-8
LC_ALL=

and 'env | grep -E '^LC_|LANG=' returns

LANG=es_ES.UTF-8
LC_ADDRESS=es_ES.UTF-8
LC_NAME=es_ES.UTF-8
LC_MONETARY=es_ES.UTF-8
LC_PAPER=es_ES.UTF-8
LC_IDENTIFICATION=es_ES.UTF-8
LC_TELEPHONE=es_ES.UTF-8
LC_MEASUREMENT=es_ES.UTF-8
LC_TIME=es_ES.UTF-8
LC_NUMERIC=es_ES.UTF-8

@eggert
Copy link
Author

eggert commented Oct 21, 2022

Mmm... but why your LANG environment variable is "C" instead of "en_US.utf8?

I don't know and it doesn't matter. I get the same result if LANG is unset, or if it's set to en_US.utf8.
Actually, with the latest Chromium, it's even a bit worse, as I get two "Permission denied" messages:

$ chromium --version
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
/bin/bash: /home/eggert/.bashrc: Permission denied
/bin/bash: /home/eggert/.bashrc: Permission denied
Chromium 106.0.5249.119 snap

And the very first time I run Chromium after a reboot and login, it's even worse:

$ chromium --version
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/cups/doc-root /usr/share/cups/doc-root none bind,ro 0 0): cannot create directory "/usr/share/cups/doc-root": permission denied
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/gimp/2.0/help /usr/share/gimp/2.0/help none bind,ro 0 0): cannot create directory "/usr/share/gimp/2.0": permission denied
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/libreoffice/help /usr/share/libreoffice/help none bind,ro 0 0): cannot create directory "/usr/share/libreoffice/help": permission denied
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/xubuntu-docs /usr/share/xubuntu-docs none bind,ro 0 0): cannot open directory "/var/lib": permission denied
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
/bin/bash: /home/eggert/.bashrc: Permission denied
/bin/bash: /home/eggert/.bashrc: Permission denied
Chromium 106.0.5249.119 snap

@sergio-costas
Copy link
Contributor

Mmm... the odd thing is that those "Permission denied" come from inside bashrc... That sounds a little bit like there is something that you set in your bashrc that dislikes being executed inside an snap...

@eggert
Copy link
Author

eggert commented Oct 21, 2022

That sounds a little bit like there is something that you set in your bashrc that dislikes being executed inside an snap...

It has nothing to do with the contents of .bashrc. I get the diagnostics even if temporarily replace .bashrc with an empty file:

$ ls -l .bashrc
-rw-rw-r-- 1 eggert eggert 0 Oct 21 00:57 .bashrc
$ cat .bashrc
$ chromium --version
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)
/bin/bash: /home/eggert/.bashrc: Permission denied
/bin/bash: /home/eggert/.bashrc: Permission denied
Chromium 106.0.5249.119 snap

The problem is that I am setting my ENV and BASH_ENV environment variables, which Bash users are allowed to do:

$ env | grep ENV
ENV=/home/eggert/.bashrc
BASH_ENV=/home/eggert/.bashrc

but snapd is disallowing access to my .bashrc. If snapd wants to disallow BASH_ENV etc, it shouldn't be passing BASH_ENV to the commands it runs on my behalf.

@sergio-costas
Copy link
Contributor

Ooook... that makes sense now.

@sergio-costas
Copy link
Contributor

But then this bug doesn't belong here... I'll comment it to the snapd people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants