1

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

Guillaume
  • 23
  • 5
  • Just to note, the version of Ubuntu you're using is not helpful to anyone that doesn't have that version; better would be to tell us which version of GNU make you're using (run `make --version`). – MadScientist Oct 21 '22 at 17:10
  • Yes I should have thought of that, I have edited my question – Guillaume Oct 24 '22 at 07:05

1 Answers1

1

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).

MadScientist
  • 92,819
  • 9
  • 109
  • 136
  • Thank you for the amazing answer ! You are right, adding a semicolon makes it work again. I did have a look closely at my PATH variable, and there was a `::` in the middle (I guess some install script did that). I guess it resolves to the current directory, the project directory, and it indeed contains a `docker` folder :) Removing the duplicated `:` fixes my problem also ! – Guillaume Oct 24 '22 at 07:42