nodejs/node · error · Exception

Not enough arguments

Error message

Not enough arguments

What it means

FlockTool.Dispatch raises Exception('Not enough arguments') when invoked with an empty args list. FlockTool emulates Linux's flock(1) for gyp on platforms lacking it; Dispatch expects args[0] to be a command name (e.g. 'flock') that it maps to an Exec<Name> method. With zero args there is no command to dispatch, so it bails immediately.

Source

Thrown at tools/gyp/pylib/gyp/flock_tool.py:27

import fcntl
import os
import struct
import subprocess
import sys


def main(args):
    executor = FlockTool()
    executor.Dispatch(args)


class FlockTool:
    """This class emulates the 'flock' command."""

    def Dispatch(self, args):
        """Dispatches a string command to a method."""
        if len(args) < 1:
            raise Exception("Not enough arguments")

        method = "Exec%s" % self._CommandifyName(args[0])
        getattr(self, method)(*args[1:])

    def _CommandifyName(self, name_string):
        """Transforms a tool name like copy-info-plist to CopyInfoPlist"""
        return name_string.title().replace("-", "")

    def ExecFlock(self, lockfile, *cmd_list):
        """Emulates the most basic behavior of Linux's flock(1)."""
        # Rely on exception handling to report errors.
        # Note that the stock python on SunOS has a bug
        # where fcntl.flock(fd, LOCK_EX) always fails
        # with EBADF, that's why we use this F_SETLK
        # hack instead.
        fd = os.open(lockfile, os.O_WRONLY | os.O_NOCTTY | os.O_CREAT, 0o666)
        if sys.platform.startswith("aix") or sys.platform == "os400":
            # Python on AIX is compiled with LARGEFILE support, which changes the

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Ensure the flock action receives at least a command name, e.g. `python flock_tool.py flock <lockfile> <cmd...>`.
  2. Inspect the gyp generator's action template that emits the flock invocation and fix empty substitutions.
  3. On Linux you can avoid the wrapper by using the native flock(1) if the generator supports it.

Example fix

# before
python tools/gyp/pylib/gyp/flock_tool.py

# after
python tools/gyp/pylib/gyp/flock_tool.py flock /tmp/build.lock ninja -C out
Defensive patterns

Strategy: validation

Validate before calling

def run_flock(args):
    if not args:
        raise SystemExit('flock_tool requires at least a command name, e.g. flock <lock> <cmd>')
    FlockTool().Dispatch(args)

Type guard

def has_command_arg(args) -> bool:
    return len(args) >= 1

Try / catch

from gyp.flock_tool import main
try:
    main(args)
except Exception as e:
    if 'Not enough arguments' in str(e):
        raise SystemExit('Usage: flock_tool.py flock <lockfile> <cmd...>')

Prevention

When it happens

Trigger: gyp invoking its flock_tool.py wrapper with no arguments (misconfigured generator or a bad $(flock) substitution); a shell/cmake rule that expands to an empty command string; manually running `python flock_tool.py` with nothing after it.

Common situations: Porting a gyp-based build to a new platform whose action template leaves the lockfile command empty; quoting bug that drops the lockfile path and command.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/a0405ec6d45a61ed. Report an issue: GitHub.