I am deploying my sinatra project via ansible, and one of the tasks is precompiling assets.
At first I stacked into question how to initialize rbenv properly.
Then, what I did is:
- name: Precompiling assets
command: bash -lc "cd {{ build_path }} && bundle exec rake assetpack:build"
But then I got error Encoding::UndefinedConversionError at assets/application.js
When I connected by ssh to server and run bundle exec rake assetpack:build
- everything worked perfectly.
So, I presumed, this is related to setting environment variables
lookup('env', 'LANG')
says it is "msg": "ru_RU.UTF-8"
but echo $LANG says it's "C" (look there).
Look to this issue. It says:
Ansible sets LANG to C on modules which don't need it
Ansible modules set "$LANG=C" automatically.
Adding environment variable didn't give desired result:
environment:
LANG: ru_RU.UTF-8
command: bash -lc "cd {{ build_path }} && bundle exec rake assetpack:build"
At the same time shell module seem to know nothing about bundle
, so this didn't work as well:
- name: Precompiling assets
command: bash -lc "cd {{ build_path }} && bundle exec rake assetpack:build"
I tried huge bunch of commands, such as export LANG=ru_RU.UTF-8
, command
module, shell
module, but nothing helps, all my attempts failed miserably.
I do not really know how to workaround this issue.
Need help!