sds/overcommit · error · Overcommit::Exceptions::InvalidCommandArgs

Command `#{args.take(5).join(' ')} ...` is longer than the m

Error message

Command `#{args.take(5).join(' ')} ...` is longer than the maximum number of bytes allowed by the operating system (#{max_command_length})

What it means

Error "Command `#{args.take(5).join(' ')} ...` is longer than the maximum number of bytes allowed by the operating system (#{max_command_length})" thrown in sds/overcommit.

Source

Thrown at lib/overcommit/command_splitter.rb:85

        results = extract_argument_lists(initial_args, splittable_args).map do |arg_list|
          Overcommit::Subprocess.spawn(arg_list, options)
        end

        Result.new(results.map(&:status), results.map(&:stdout), results.map(&:stderr))
      end

      private

      # Given a list of prefix arguments and suffix arguments that can be split,
      # returns a list of argument lists that are executable on the current OS
      # without exceeding command line limitations.
      def extract_argument_lists(args, splittable_args)
        # Total number of bytes needed to contain the prefix command
        # (including byte separators between each argument)
        prefix_bytes = (args.size - 1) + args.reduce(0) { |sum, arg| sum + arg.bytesize }

        if prefix_bytes >= max_command_length
          raise Overcommit::Exceptions::InvalidCommandArgs,
                "Command `#{args.take(5).join(' ')} ...` is longer than the " \
                'maximum number of bytes allowed by the operating system ' \
                "(#{max_command_length})"
        end

        arg_lists = []
        index = 0
        while index <= splittable_args.length - 1
          arg_list, index = arguments_under_limit(splittable_args,
                                                  index,
                                                  max_command_length - prefix_bytes)
          arg_lists << args + arg_list
        end

        arg_lists
      end

      # @return [Array<Array<String>, Integer>] tuple of arguments and new index

View on GitHub (pinned to fee0cd74b2)

Solutions

  1. Shorten the fixed command prefix (executable plus flags) so its total byte size stays under the OS command-length limit (2048 bytes on Windows, half of `getconf ARG_MAX` elsewhere).
  2. Move long option values into a config file or environment variables instead of passing them on the command line.
  3. Reduce the number of prefix arguments passed to the hook command.

When it happens

Trigger: Thrown at lib/overcommit/command_splitter.rb:85 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sds/overcommit@fee0cd74b2 (2026-08-23). Data as JSON: /api/errors/4be52d689b0ce0cf. Report an issue: GitHub.