With this in a Makefile:
single:
docker network inspect -f '{{ .IPAM }}' web-proxy
double:
docker network inspect -f "{{ .IPAM }}" web-proxy
make single
fails with make: docker: Permission denied
while make double
succeeds. Both commands work if I input them directly in my bash.
It happens only since I upgraded to Ubuntu 22.04.1 (from the 22.04). I have docker 20.10.20, bash 5.1.16 and GNU Make 4.3
Any idea were it can come from ? From what I have read the Makefile doesn't care about quotes: https://stackoverflow.com/a/23332194
CodePudding user response:
I don't know why updating your system made a difference, but this is almost certainly related to a bug in gnulib (that GNU make uses).
If you add a semicolon to the end of the docker
command line in the single
target I'll bet it will work again.
The bug is this: if some directory on your PATH
contains a subdirectory with the name of a command you want to invoke, then if make
attempts to run that command directly (without using a shell) it will fail because it tries to "run" that directory. So for example if you have /my/dir
in PATH
and the directory /my/dir/docker/.
exists, you will get this error (for simple docker
commands).
The "double" target works because (due to the {{
) make's trivial parser decides that this command it not "simple enough" to parse directly, and it runs the shell to do it; the shell doesn't get confused by that directory.
You can (1) add the semicolon as above, or (2) figure out why some directory on your PATH
contains a docker
subdirectory and remove it.
The next release of GNU make (probably released by the end of the month) will fix this issue (includes a newer version of the gnulib module, with the fix).