Search code examples
makefile

Makefile Syntax error: word unexpected (expecting ")")


I have the following script in Makefile which is giving me the error

after entering make start-test, The script should run command locust -f tests/load/ if .env file is present else it should not run the command.

start-test:
# Check if .env file exists
        ifeq ($(wildcard $(.env)),yes)
            include .env
# If the file doesn't exist, execute this rule
        all:
            echo ".env file does not exist"
        else
# If the file exists, execute this rule
        all:
            echo ".env file exists"
            locust -f tests/load/
        endif

Syntax error: word unexpected (expecting ")")


Solution

  • Given the description in the comment, you can do this:

    start-test:
            if test -f .env; then locust -f tests/load/; fi
    

    This will work on any system which provides a POSIX shell.