0

On Mac OS X, running scalene --version (a python package) on the command line works but running the same line in a Makefile gives an error.

$ scalene --version
Scalene version 1.5.15 (2022.11.16)

Makefile:

check-deps:
    scalene --version
$ make check-deps
Scalene version 1.5.15 (2022.11.16)
make: *** [check-deps] Error 255
offwhitelotus
  • 1,049
  • 9
  • 15
  • 3
    It gives an error because the program returns a bogus exit code. – MadScientist Dec 19 '22 at 23:36
  • 2
    If you run at your shell prompt `scalene --version` then immediately at the next line run `echo $?` to show the exit code you'll see it's not `0` (which means success) it's something else. – MadScientist Dec 19 '22 at 23:37
  • 2
    If you want make to ignore that error, you have to tell it to do so. One way is to use the `-` prefix, like: `check-deps: ; - scalene --version`. It will print a message but won't fail. Another way is to use the shell to avoid returning a bogus error code; something like `check-deps: ; scalene --version || true` which always returns true. But if your goal is to see if the `scalene` program runs correctly, this won't help because it will ALWAYS return true. – MadScientist Dec 19 '22 at 23:40
  • 2
    It's unfortunate that this program `scalene` has this problem (that it exits with an error, not success, when you run `scalene --version`). If you know it always returns 255 you could check for that code and succeed. – MadScientist Dec 19 '22 at 23:41

1 Answers1

0

Running scalene --version at the command line followed by echo $? gives 255.

Based on the comments above, I tried both suggestions, and they both work with slightly different outputs.

If the Makefile is like this

check-deps:
    scalene --version || true

calling the above like make check-deps gives

Scalene version 1.5.15 (2022.11.16)
check-deps completed successfully

When the Makefile is like this

check-deps:
    - scalene --version

calling make check-deps gives

Scalene version 1.5.15 (2022.11.16)
make: [check-deps] Error 255 (ignored)
check-deps completed successfully

Thanks for the help, MadScientist.

offwhitelotus
  • 1,049
  • 9
  • 15