Package: ansible
Severity: important
Version: 2.10.7+merged+base+2.10.8+dfsg-1
Control: tags -1 patch

Dear maintainers,

When running a `yarn` command via ansible on a Bullseye machine, it
fails with this error:

fatal: [XXX.XXX.XXX.XXX]: FAILED! => {"changed": false, "cmd":
"/usr/bin/yarnpkg install --non-interactive --no-emoji", "msg": "error:
unknown option '--no-emoji'", "rc": 1, "stderr": "error: unknown option
'--no-emoji'\n", "stderr_lines": ["error: unknown option '--no-emoji'"],
"stdout": "", "stdout_lines": []}

It indeed appears this flag has been gone from `yarnpkg` since 2017 [1],
the new flag being `--emoji [bool]`. This parameter defaults to `false`,
so there's actually no need to pass it at all.

I'm marking this as important, since even when not using the ansible
yarn module, ansible still fails.

This is the handler I'm running to get the previously-mentioned error:

- name: yarn install
  yarn:
    executable: /usr/bin/yarnpkg
    path: /srv/vogol/frontend

I've attached a patch to this bug report. I've tested said patch and it
seems to solve the issue.

Cheers, and thanks for maintaining ansible in Debian.

PS: I'm not sure why the yarn.py file is duplicated by the way (it's in
ansible_collections/community/general/plugins/modules/yarn.py and
ansible_collections/community/general/plugins/modules/packaging/language/yarn.py).
The same exact file.

[1]:
https://github.com/yarnpkg/yarn/commit/10b82bb063c2e2feee669ddb9dfaf4126b74c7a7#diff-867becf4a9c2c6c6d4e7c1278750724e

-- 
  ⢀⣴⠾⠻⢶⣦⠀
  ⣾⠁⢠⠒⠀⣿⡁  Louis-Philippe Véronneau
  ⢿⡄⠘⠷⠚⠋   po...@debian.org / veronneau.org
  ⠈⠳⣄
diff --git a/debian/patches/0008-fix-yarn-emoji-error.patch b/debian/patches/0008-fix-yarn-emoji-error.patch
new file mode 100644
index 000000000..39279728a
--- /dev/null
+++ b/debian/patches/0008-fix-yarn-emoji-error.patch
@@ -0,0 +1,31 @@
+yarnpkg in Debian doesn't have the --no-emoji flag anymore, so using any yarn
+command via ansible fails. The new flag (--emoji [boo]) defaults to false, so
+there's no need to pass anything.
+Index: ansible/collections-debian-merged/ansible_collections/community/general/plugins/modules/packaging/language/yarn.py
+===================================================================
+--- ansible.orig/collections-debian-merged/ansible_collections/community/general/plugins/modules/packaging/language/yarn.py
++++ ansible/collections-debian-merged/ansible_collections/community/general/plugins/modules/packaging/language/yarn.py
+@@ -205,9 +205,6 @@ class Yarn(object):
+                 cmd.append('--registry')
+                 cmd.append(self.registry)
+ 
+-            # always run Yarn without emojis when called via Ansible
+-            cmd.append('--no-emoji')
+-
+             # If path is specified, cd into that path and run the command.
+             cwd = None
+             if self.path and not self.globally:
+Index: ansible/collections-debian-merged/ansible_collections/community/general/plugins/modules/yarn.py
+===================================================================
+--- ansible.orig/collections-debian-merged/ansible_collections/community/general/plugins/modules/yarn.py
++++ ansible/collections-debian-merged/ansible_collections/community/general/plugins/modules/yarn.py
+@@ -205,9 +205,6 @@ class Yarn(object):
+                 cmd.append('--registry')
+                 cmd.append(self.registry)
+ 
+-            # always run Yarn without emojis when called via Ansible
+-            cmd.append('--no-emoji')
+-
+             # If path is specified, cd into that path and run the command.
+             cwd = None
+             if self.path and not self.globally:
diff --git a/debian/patches/series b/debian/patches/series
index b880a37b9..5da2abf08 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,3 +2,4 @@
 0003-preserve-debian-dir.patch
 0005-use-py3.patch
 0007-fix-interpreter-fallback.patch
+0008-fix-yarn-emoji-error.patch

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to