alvin2ye / notes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8)

alvin2ye opened this issue · comments

用docker 时因为包安装的少, 有几率抛这个错


ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8):
    46:     link rel="apple-touch-startup-image" href="/demo/img/splash/ipad-portrait.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)"
    47:     link rel="apple-touch-startup-image" href="/demo/img/splash/iphone.png" media="screen and (max-device-width: 320px)"
    48:
    49:     = include_gon
    50:     /- if Rails.env.development?
    51:       /script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react-with-addons.js"
    52:       /script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react-dom.js"
  app/views/layouts/application.html.slim:49:in `_app_views_layouts_application_html_slim__2886400402124914098_47450135072760'

查下locale

root@a719268c75f0:/app# 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=

解决方法:

apt-get install locales
echo 'en_US.UTF-8 UTF-8' > locale-gen
locale-gen

如果是Dockerfile 里

RUN apt-get install locales
RUN echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen
RUN locale-gen
ENV LC_ALL en_US.UTF-8

查 locale

LANG=
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"