0

I've got this in a docker build file: RUN 'echo "y" | /usr/bin/task'

When building, this error is thrown:

 => ERROR [tool_config  9/11] RUN 'echo "y" | /usr/bin/task'                                                                             0.2s
------
 > [tool_config  9/11] RUN 'echo "y" | /usr/bin/task':
#15 0.164 /bin/sh: echo "y" | /usr/bin/task: not found
------
executor failed running [/bin/sh -c 'echo "y" | /usr/bin/task']: exit code: 127

The command runs fine when manually run from insside the container. The task command is definitely installed.

Without without quotes, RUN echo "y" | task gives:

 => ERROR [tool_config  9/11] RUN echo "y" | /usr/bin/task                                                                               0.2s
------
 > [tool_config  9/11] RUN echo "y" | /usr/bin/task:
#15 0.176 A configuration file could not be found in /root
#15 0.176
#15 0.176 Would you like a sample /root/.taskrc created, so Taskwarrior can proceed? (yes/no) No matches.
------
executor failed running [/bin/sh -c echo "y" | /usr/bin/task]: exit code: 1
StevieD
  • 6,925
  • 2
  • 25
  • 45
  • I don't want to be that guy, but can you double-check again to ensure that `/usr/bin/task` exists in that specific build step (build step no. 9)? You can cross-reference with a command that should be guaranteed to work: `echo "y" | /usr/bin/base64` – Lee Kai Xuan Dec 16 '22 at 02:04
  • I get the same error with /usr/bin/base64 – StevieD Dec 16 '22 at 02:07
  • 1
    The entire `RUN` command is in single quotes, which causes the shell to interpret it as a single shell word – the spaces and pipe are part of the filename it's looking for. Does deleting the outermost quotes help? – David Maze Dec 16 '22 at 02:08
  • Tried that, but I'll update OP as the output is slightly different. – StevieD Dec 16 '22 at 02:11
  • OK, I think I know what's happening. The `task` command is returning "no matches" because there are no tasks created yet which is showing as an error code causing docker to check. – StevieD Dec 16 '22 at 02:28

1 Answers1

0

The problem was the task command was returning "No matches" because no tasks had yet been created so the command exited with an error code of 1 and docker choked.

Fix is simple as per https://stackoverflow.com/a/30717108/1641112:

RUN echo "y" | task; exit 0;

StevieD
  • 6,925
  • 2
  • 25
  • 45