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

After Installation on macOS: Error "unknown locale: UTF-8" #197

Closed
couchdeveloper opened this issue May 25, 2019 · 2 comments
Closed

After Installation on macOS: Error "unknown locale: UTF-8" #197

couchdeveloper opened this issue May 25, 2019 · 2 comments

Comments

@couchdeveloper
Copy link

couchdeveloper commented May 25, 2019

Hi Everyone,

this tool looks very promising and I decided to take a look at it.

So, I tried to install gitinspector first. There's no installation instruction in the README file, but elsewhere in the Documentation, it tells me that npm can be used. So I tried installing gitinspector on macOS via npm. Using brew as installer would be a nice option, too ;)

After figuring that it requires sudo (the docs should mention this), I was able to run the installer successfully:

sudo npm i -g gitinspector
Password:
/usr/local/bin/gitinspector -> /usr/local/lib/node_modules/gitinspector/gitinspector.py
+ [email protected]
added 2 packages from 12 contributors in 0.382s

First thing I recognised was an issue with the locale on the system resulting in an error message in the console when trying to launch gitinspector:

...
...
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 562, in getlocale
    return _parse_localename(localename)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 475, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

It seems like, this is a known problem (at least on macOS and Python):
Suggested Fix:

Ensure that LC_ALL and LANG is set appropriately in the environment when starting a python program. For example, put this into your .profile and ensure it will be read by your current shell:

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

Once I did this, I was able to launch gitinspector without error.

However, I am not sure, what version I got here, since the newest tag in the repo is labeled "0.4.4" but the installer says "0.5.0-dev-2" and there's no tag like this in the repo. This is confusing.

Also, I don't think, I got the current version with npm. What's the preferred way to install it on macOS?

By the way, on macOS, this is probably the default which we get with command locale on the console:

$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

That is, we require to set LANG and LC_ALL when running Python and this program accesses the locale.

$ python
Python 2.7.10 (default, Feb 22 2019, 21:55:15) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
@cytown
Copy link

cytown commented Jul 1, 2019

LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 python2 gitinspector.py

@adam-waldenberg
Copy link
Member

This is an old issue covered several times before. Some versions of OSX are incorrectly setup. Not a bug in gitinspector per say, but rather a problem in your system.

Closing this.

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

3 participants