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

LANG variable is blank by default in Butterfly #141

Open
ali-p-q opened this issue Mar 23, 2017 · 5 comments
Open

LANG variable is blank by default in Butterfly #141

ali-p-q opened this issue Mar 23, 2017 · 5 comments

Comments

@ali-p-q
Copy link

ali-p-q commented Mar 23, 2017

I was trying to run a python script, but it was failing with

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2850: ordinal not in range(128)

It turns out the problem was that the LANG variable is blank in Butterfly server. So are LANGUAGE and LC_ALL. All the other LC variables are set to POSIX.

I'm opening Butterfly in Chrome, running it from a Ubuntu Trusty64 machine set up with Vagrant and Chef, using Virtual Box.

This is what I see when I run locale from Butterffly

vagrant@<my_user>~ % locale LANG= LANGUAGE= LC_CTYPE="POSIX" LC_NUMERIC="POSIX" LC_TIME="POSIX" LC_COLLATE="POSIX" LC_MONETARY="POSIX" LC_MESSAGES="POSIX" LC_PAPER="POSIX" LC_NAME="POSIX" LC_ADDRESS="POSIX" LC_TELEPHONE="POSIX" LC_MEASUREMENT="POSIX" LC_IDENTIFICATION="POSIX" LC_ALL=

And this is what I see when I run locale from the Ubuntu virtual machine from where I start Butterfly server.

vagrant@<my_user>~ % locale 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=

Does Butterfly support anything else than POSIX? How to set up the default language variables for Butterfly?

@paradoxxxzero
Copy link
Owner

paradoxxxzero commented Mar 24, 2017

This means butterfly failed to get your browser environment and therefore has no LANG defined.
What's your setup? (os, ...)

@ali-p-q
Copy link
Author

ali-p-q commented Mar 24, 2017 via email

@ali-p-q
Copy link
Author

ali-p-q commented Mar 24, 2017

Solved it temporarily using

$ sudo butterfly.server.py --host=myhost --port=57575 --login --unsecure instead of $ sudo butterfly.server.py --host=myhost --port=57575 (with certificates)

@paradoxxxzero
Copy link
Owner

It seems to work with --login because it uses su and su does some initialisations but it should also work without it as the shell is run with interactive and login arguments.

What's your shell?
In a regular terminal, what gives you: env -i bash -l -c "env"

@ali-p-q
Copy link
Author

ali-p-q commented Mar 24, 2017

I think I've got your point. I'm using zsh. When I run the command you asked about I get the output below, which is missing a ton of stuff compared to what env alone outputs.

% env -i bash -l -c "env" PWD=/home/vagrant NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript SHLVL=1 _=/usr/bin/env

This is what I get if I run the same command for zsh instead of bash (which is also missing a lot, notably LANG and LC_ALL)

% env -i zsh -l -c "env" HOME=/home/vagrant LOGNAME=vagrant SHLVL=0 PWD=/home/vagrant OLDPWD=/home/vagrant _=/usr/bin/env

I'm running the following commands as part of a bootstrap.sh before ChefSolo installs python, zsh, butterfly etc.

#!/usr/bin/env bash

#Configure locale for bash
sudo cp /lang.sh /etc/default/lang.sh

This is the content of lang.sh

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

I'm running the same commands again with zsh's shebang (#!/usr/bin/env zsh) after zsh is provisioned, but I don't think that makes any difference.

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