\n isn't expanded to a new line character in script

My before_script looks like this:

before_script:
- echo "---\nsources:\n- https://xxx/" > ~/.gemrc
- cat ~/.gemrc
- gem install bundler

Output:

$ echo "---\nsources:\n- https://xxx/" > ~/.gemrc
$ cat ~/.gemrc
---\nsources:\n- https://xxx/
$ gem install bundler
Failed to load /root/.gemrc because it doesn't contain valid YAML hash
Successfully installed bundler-1.12.5

\n inside "double quotes" wasn't expanded to a new line character. In a "normal" environment \n would be converted to a new line character.

% echo "---\nsources:\n- https://xxx/" > /tmp/test 
% cat /tmp/test
---
sources:
- https://xxx/

I use GitLab.com but I use gitlab-ci-multi-runner exec docker build locally.

gitlab-ci-multi-runner 1.4.1-1
nowaker@nwkr-desktop ~ % pacman -Q gitlab-ci-multi-runner
gitlab-ci-multi-runner 1.4.1-1
nowaker@nwkr-desktop ~ % gitlab-ci-multi-runner --version
Version:      dev
Git revision: HEAD
Git branch:   HEAD
GO version:   go1.6.3
Built:        Mon, 29 Aug 2016 19:57:59 -0500
OS/Arch:      linux/amd64