Utf 8 Can';t通过ansible预购sinatra资产

Utf 8 Can';t通过ansible预购sinatra资产,utf-8,sinatra,ansible,precompile,sinatra-assetpack,Utf 8,Sinatra,Ansible,Precompile,Sinatra Assetpack,我正在通过ansible部署我的sinatra项目,其中一项任务是预编译资产 起初我开始怀疑 然后,我做的是: - name: Precompiling assets command: bash -lc "cd {{ build_path }} && bundle exec rake assetpack:build" 但随后我在assets/application.js上得到了errorEncoding::UnfinedConversionError 当我通过ssh连接到服

我正在通过ansible部署我的sinatra项目,其中一项任务是预编译资产

起初我开始怀疑

然后,我做的是:

- name: Precompiling assets
  command: bash -lc "cd {{ build_path }} && bundle exec rake assetpack:build"
但随后我在assets/application.js上得到了error
Encoding::UnfinedConversionError

当我通过ssh连接到服务器并运行bundle-exec-rake-assetpack:build
时,一切都很正常。 因此,我推测,这与

lookup('env','LANG')
说它是
“msg”:“ru_ru.UTF-8”
但echo$LANG说它是“C”()

看。它说:

Ansible在不需要的模块上将LANG设置为C

Ansible模块自动设置“$LANG=C”

添加环境变量未得到期望的结果:

同时,shell模块似乎对
捆绑包一无所知,因此这也不起作用:

我尝试了大量的命令,例如
export LANG=ru_ru.UTF-8
command
module,
shell
module,但是没有任何帮助,我所有的尝试都失败了

我真的不知道如何解决这个问题


需要帮助

命令
模块不用于多个shell命令<应改用代码>外壳
模块:

- name: Precompiling assets
  shell: bundle exec rake assetpack:build chdir={{ build_path }}
运行
bundle
之前需要的任何环境变量都可以按照下一个示例进行配置:

- name: Precompiling assets
  shell: RAILS_ENV=development bundle exec rake assetpack:build chdir={{ build_path }}

命令
模块不适用于多个shell命令<应改用代码>外壳模块:

- name: Precompiling assets
  shell: bundle exec rake assetpack:build chdir={{ build_path }}
运行
bundle
之前需要的任何环境变量都可以按照下一个示例进行配置:

- name: Precompiling assets
  shell: RAILS_ENV=development bundle exec rake assetpack:build chdir={{ build_path }}

我不仅应该更改
LANG
变量,还应该同时更改
LANG
LC\u ALL

- name: Precompiling assets
  environment:
    LANG: "ru_RU.UTF-8"
    LC_ALL: "ru_RU.UTF-8"
  command: bash -lc "cd {{ build_path }} && bundle exec rake assetpack:build"

这对我有用

我不仅应该更改
LANG
变量,还应该同时更改
LANG
LC\u ALL

- name: Precompiling assets
  environment:
    LANG: "ru_RU.UTF-8"
    LC_ALL: "ru_RU.UTF-8"
  command: bash -lc "cd {{ build_path }} && bundle exec rake assetpack:build"

这对我有用

问题本身不是关于命令和shell模块之间的区别,而是关于我在编译资产时遇到的编码问题。shell模块不知道
rake
bundle
问题本身不是关于命令和shell模块之间的区别,这是关于我在编译资产时遇到的编码问题。shell模块不知道
rake
bundle