Flex: [Bug] Makefile error: Need an operator

Created on 18 Jun 2017  路  25Comments  路  Source: symfony/flex

Composer version 1.4.2 2017-05-17 08:17:52 PHP 7.1.3 FreeBSD 10.3

composer create-project "symfony/skeleton:^3.3" demo

```composer create-project "symfony/skeleton:^3.3" demo
Installing symfony/skeleton (v3.3.2)

  • Installing symfony/skeleton (v3.3.2): Loading from cache
    Created project in demo
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Package operations: 22 installs, 0 updates, 0 removals
  • Installing symfony/flex (v1.0.7): Loading from cache
  • Installing symfony/stopwatch (v3.3.2): Loading from cache
  • Installing symfony/routing (v3.3.2): Loading from cache
  • Installing symfony/polyfill-mbstring (v1.4.0): Loading from cache
  • Installing psr/log (1.0.2): Loading from cache
  • Installing symfony/debug (v3.3.2): Loading from cache
  • Installing symfony/http-foundation (v3.3.2): Loading from cache
  • Installing symfony/event-dispatcher (v3.3.2): Loading from cache
  • Installing symfony/http-kernel (v3.3.2): Loading from cache
  • Installing symfony/finder (v3.3.2): Loading from cache
  • Installing symfony/filesystem (v3.3.2): Loading from cache
  • Installing psr/container (1.0.0): Loading from cache
  • Installing symfony/dependency-injection (v3.3.2): Loading from cache
  • Installing symfony/config (v3.3.2): Loading from cache
  • Installing symfony/class-loader (v3.3.2): Loading from cache
  • Installing psr/simple-cache (1.0.0): Loading from cache
  • Installing psr/cache (1.0.1): Loading from cache
  • Installing symfony/cache (v3.3.2): Loading from cache
  • Installing doctrine/cache (v1.6.1): Loading from cache
  • Installing symfony/framework-bundle (v3.3.2): Loading from cache
  • Installing symfony/yaml (v3.3.2): Loading from cache
  • Installing symfony/dotenv (v3.3.2): Loading from cache
    Writing lock file
    Generating autoload files
    Symfony operations: 2 recipes
  • Configuring symfony/flex (1.0): From github.com/symfony/recipes:master
  • Configuring symfony/framework-bundle (3.3): From github.com/symfony/recipes:master
    Executing script make cache-warmup [KO]
    [KO]
    Script make cache-warmup returned with error code 1
    !! make: "/home/gander/demo/Makefile" line 1: Need an operator
    !! make: "/home/gander/demo/Makefile" line 3: Need an operator
    !! make: Fatal errors encountered -- cannot continue
    !!
    !! make: stopped in /home/gander/demo
    !!
    !!
    ```

Most helpful comment

Closing as Makefiles are gone. symfony/console is now a requirement in the base skeleton.

All 25 comments

Can you please show the contents of the generated Makefile?

http://gander.pl/Makefile

ifndef APP_ENV
    include .env
endif

###> symfony/framework-bundle ###
cache-clear:
    @test -f bin/console && bin/console cache:clear --no-warmup || rm -rf var/cache/*
.PHONY: cache-clear

cache-warmup: cache-clear
    @test -f bin/console && bin/console cache:warmup || echo "cannot warmup the cache (needs symfony/console)"
.PHONY: cache-warmup

CONSOLE=bin/console
sf_console:
    @test -f $(CONSOLE) || printf "Run \033[32mcomposer require cli\033[39m to install the Symfony console.\n"
    @exit

serve_as_sf: sf_console
    @test -f $(CONSOLE) && $(CONSOLE)|grep server:start > /dev/null || ${MAKE} serve_as_php
    @$(CONSOLE) server:start || exit 1

    @printf "Quit the server with \033[32;49mbin/console server:stop.\033[39m\n"

serve_as_php:
    @printf "\033[32;49mServer listening on http://127.0.0.1:8000\033[39m\n";
    @printf "Quit the server with CTRL-C.\n"
    @printf "Run \033[32mcomposer require symfony/web-server-bundle\033[39m for a better web server\n"
    php -S 127.0.0.1:8000 -t web

serve:
    @${MAKE} serve_as_sf
.PHONY: sf_console serve serve_as_sf serve_as_php
###< symfony/framework-bundle ###

I looked in google for such bugs and found that on FreeBSD people solved problems with make using gmake. So I created a symlink to gmake called make, and it works. But this is not a solution to the problem.

The makefile doesn't work on Windows either, unless you use WSL or Cygwin. I'm starting to think that the makefile wasn't a nice solution for _every_ developer, just because of the windows problem (and there is still a lot of people using windows). It's another subject, but I wonder if we should open an issue for Windows too 馃槙

@Pierstoval I prefer simple POSIX compatible shell script (it works with busybox - only 414 KB exe file for windows):

#!/bin/sh
set -e

###> symfony/framework-bundle ###
cmd_serve_as_php() { ## Run application
    printf "\033[32;49mServer listening on http://127.0.0.1:8000\033[39m\n"
    php -S 127.0.0.1:8000 -t web
}
###< symfony/framework-bundle ###

# Simple Shell Task Runner
_header(){
    printf "Application \033[1;33m%s\033[0m: usage %s [command]\n\n" "app" "$0"
}

_commands(){
    printf "\033[33mCommands:\033[0m\n"
    PATTERN="^\s*cmd_([a-zA-Z_-]+)\s*\(\s*\)[ \{]*"
    grep -E "$PATTERN" < "$0" | sort | sed -r -e "s/$PATTERN/\1/" | awk 'BEGIN {FS = "##[ \t]*"}; {printf "  \033[36m%-15s\033[0m %s\n", $1, $2}'
}

if [ "$1" = '' ] || [ "$1" = '-h' ] || [ "$1" = '--help' ]; then
    _header
    _commands
elif command -v "cmd_${1}" > /dev/null; then
    command=$1 && shift && cmd_"${command}" "$@"
else
    _header
    printf "\033[30;41mCommand \"%s\" doesn't exist.\033[0m\n\n" "$1" >&2 && _commands >&1 && exit 1
fi

UP

And what about that further? This is a real problem. I can not create a flex based project on my hosting. I'm lucky in the misfortune that I can work around creating a symlink for the proper make, but this creates a lot of security issues in my account (local bin directory at the beginning of the $ PATH path list). Or imagine a shell hosting without make, what then?

Not much to say in fact, you are using the FreeBSD version of Make which is not compatible with the syntax of the GNU make.

You gave the solution yourself. You can install the GNU version of Make and use that. Symlinking is not necessary (except for the composer hooks, which you can disable), you can simply call the gmake command instead of the make command.

This should be closed.

@iammichiel please provide me commands which should I run for equivalent result for:
composer create-project "symfony/skeleton:^3.3" flex

Hello,
My recommendation is that it uses docker for windows and this image docker-symfony-drupal that I create is very complete to use symfony and in specific flex
or
You install make for windows (not probe) in this link make-for-windows

@lliccien make for windows doesn't work either (I have tested many make versions on windows), it seems the makefile's syntax is not fully compatible with it 馃槙

I think, the windows problem should not be ignored. In my work i stuck in windows7, so no WSL available. Also deployment on (older) Windows Server (with IIS) could be a mess.

I think, the windows problem should not be ignored. In my work i stuck in windows7, so no WSL available.

But you can still use Cygwin or Mingw (the latter is bundled with Git for Windows), which is the recommended way to have a UNIX environment without WSL. It's can even be better than a VM because it consumes less resources on your machine and still uses native components.

Also deployment on (older) Windows Server (with IIS) could be a mess.

Is there statistics about Windows Server usage with Symfony? The use percentage could be useful to ask for another decision about the Makefile.

Tried the Mingw way as already installed with git fow windows. Unfortunately make is no longer integrated. Installed Mingw and got it fly.

What was your error winth Mingw make ?

Error was "Command not found" since "make" is not more included in the git-windows-mingw.

You should use mingw32-make when you use Mingw with Git for windows.

We could use a solution to indicate the path to the make that will be used to start the Makefile. Any ideas?

If you have gmake installed on server, you can create BSDmakefile, which will be used instead of Makefile and pass execution to gmake with it. E. g. node.js has this approach https://github.com/nodejs/node/blob/master/BSDmakefile.

But yeah, you still need gmake, it will just make life little easier for existing project, won't work with composer create-project.

Hello to install flex over windows without problems, you must to install first these packages

http://gnuwin32.sourceforge.net/packages/coreutils.htm
http://gnuwin32.sourceforge.net/packages/make.htm

after SET in your windows enviromental vars something like "C:\Program Files (x86)\GnuWin32\bin" where this is your path of GnuWin bin directory

Same issue on FreeBSD. I'll wait before using Flex.

Hello,
the "only real" issue here is with BSD as far as I understand (make can be installed on Windows, for whom who don't want to use WSL or Docker).

It's an opinion, but please keep the "make" way to do in Flex :+1:

twitter discussion and survey => https://twitter.com/fabpot/status/918836623143399424

(make can be installed on Windows, for whom who don't want to use WSL or Docker).

Yep but even with make on windows, it still doesn't work 馃槙 Anytime I'm using flex on my machine I have to switch to WSL. In the end it's not _that_ painful, it's just more work, and maybe a few inconsistencies between windows and wsl

Closing as Makefiles are gone. symfony/console is now a requirement in the base skeleton.

Was this page helpful?
0 / 5 - 0 ratings