読者です 読者をやめる 読者になる 読者になる

DRY

Web関連の技術の事、食事/お酒の事、旅行の事など

dotcloudでlocaleエラー

久々にOSXでdotcloud動かしてみようと思い、コマンド叩いたらlocaleのエラーが出たので解決方法をメモしておきます。


$ dotcloud
Traceback (most recent call last):
File "/usr/local/bin/dotcloud", line 16, in
cli = CLI(endpoint=url, debug=debug, username=username)
File "/Library/Python/2.7/site-packages/dotcloud/ui/cli.py", line 42, in __init__
user_agent=self._build_useragent_string(),
File "/Library/Python/2.7/site-packages/dotcloud/ui/cli.py", line 72, in _build_useragent_string
(langcode, encoding) = locale.getdefaultlocale()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 496, in getdefaultlocale
return _parse_localename(localename)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 428, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
exit 1
という感じでlocaleのエラーがでます。

ここに解決方法が乗っていたので、とりあえず.bash_profileで解決しました。
ValueError: unknown locale: UTF-8 · Issue #23 · dotcloud/dotcloud-cli · GitHub
正確にはMacのset localeの設定との相性のようです。


$ vi ~/.bash_profile
以下pwdの右辺を変更して記載

if [ [ $(pwd) == *yourfolderappname* ] ]
then
export LANG="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_MONETARY="en_US.UTF-8"
export LC_NUMERIC="en_US.UTF-8"
export LC_TIME="en_US.UTF-8"
export LC_ALL=
echo -e "=== CLI tweak on locale activated! ==="
fi

$ source ~/.bash_profile

$ dotcloud
nagashima@k16nagashima-no-MacBook-Pro[~/Downloads/gb_manage-master]$ dotcloud
error: too few arguments
usage: dotcloud [-h] [--application APPLICATION] [--version]

{setup,check,list,connect,disconnect,create,destroy,app,activity,info,url,status,open,run,push,deploy,dlist,dlogs,logs,env,scale,restart,domain,revisions}
...

dotcloud CLI

positional arguments:
{setup,check,list,connect,disconnect,create,destroy,app,activity,info,url,status,open,run,push,deploy,dlist,dlogs,logs,env,scale,restart,domain,revisions}
setup Setup the client authentication
check Check the installation and authentication
list List all applications
connect Connect a local directory to an existing application
disconnect Disconnect the current directory from its application
create Create a new application
destroy Destroy an existing app
app Display the application name connected to the current
directory
activity Display your recent activity
info Get information about the application or service
url Display the URL(s) for the application
status Probe the status of a service
open Open the application in the browser
run Open a shell or run a command inside a service
instance
push Push the code
deploy Deploy a specific version
dlist List recent deployments
dlogs Review past deployments or watch one in-flight
logs View your application logs or watch logs live
env Manipulate application environment variables
scale Scale services
restart Restart a service instance
domain Manage domains for the service
revisions Display all the known revision of the application

optional arguments:
-h, --help show this help message and exit
--application APPLICATION, -A APPLICATION
Specify the application
--version, -v show program's version number and exit
exit 1