{"record":{"id":"920aa7b411327312","repo":"google/python-fire","slug":"findexecutableonpath-0-failed-because-first","errorCode":null,"errorMessage":"FindExecutableOnPath({0},...) failed because first argument must not have an extension.","messagePattern":"FindExecutableOnPath\\((.+?),\\.\\.\\.\\) failed because first argument must not have an extension\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"fire/console/files.py","lineNumber":98,"sourceCode":"    executable: The name of the executable to find.\n    path: A list of directories to search separated by 'os.pathsep'.  If None\n      then the system PATH is used.\n    pathext: An iterable of file name extensions to use.  If None then\n      platform specific extensions are used.\n    allow_extensions: A boolean flag indicating whether extensions in the\n      executable are allowed.\n\n  Returns:\n    The path of 'executable' (possibly with a platform-specific extension) if\n    found and executable, None if not found.\n\n  Raises:\n    ValueError: if executable has a path or an extension, and extensions are\n      not allowed, or if there's an internal error.\n  \"\"\"\n\n  if not allow_extensions and os.path.splitext(executable)[1]:\n    raise ValueError('FindExecutableOnPath({0},...) failed because first '\n                     'argument must not have an extension.'.format(executable))\n\n  if os.path.dirname(executable):\n    raise ValueError('FindExecutableOnPath({0},...) failed because first '\n                     'argument must not have a path.'.format(executable))\n\n  if path is None:\n    effective_path = _GetSystemPath()\n  else:\n    effective_path = path\n  effective_pathext = (pathext if pathext is not None\n                       else _PlatformExecutableExtensions(\n                           platforms.OperatingSystem.Current()))\n\n  return _FindExecutableOnPath(executable, effective_path,\n                               effective_pathext)\n","sourceCodeStart":80,"sourceCodeEnd":115,"githubUrl":"https://github.com/google/python-fire/blob/716bbc23d7eca949fdb682172283c8d18f742cb6/fire/console/files.py#L80-L115","documentation":"FindExecutableOnPath refuses to search when extensions are disallowed and the given executable name already contains an extension (os.path.splitext yields a non-empty suffix). The function's contract is to locate a bare executable name and try allowed extensions itself; passing a pre-extensioned name would be ambiguous or redundant.","triggerScenarios":"FindExecutableOnPath('git.exe', allow_extensions=False) or FindExecutableOnPath('archive.tar') — any name whose splitext()[1] is non-empty while allow_extensions is False.","commonSituations":"Windows users habitually appending .exe; passing filenames copied from a directory listing; confusing this API with a plain file-existence check.","solutions":["Strip the extension before calling: use os.path.splitext(name)[0].","Pass allow_extensions=True if the name legitimately includes an extension.","Call with just the base command name, e.g. 'git' not 'git.exe'."],"exampleFix":"// before\nFindExecutableOnPath('git.exe', allow_extensions=False)\n// after\nFindExecutableOnPath(os.path.splitext('git.exe')[0], allow_extensions=False)  # 'git'","handlingStrategy":"validation","validationCode":"import os\nif not allow_extensions and os.path.splitext(executable)[1]:\n    executable = os.path.splitext(executable)[0]","typeGuard":"def is_bare_executable_name(name: str) -> bool:\n    return os.path.splitext(name)[1] == ''","tryCatchPattern":"try:\n    exe = files.FindExecutableOnPath(executable)\nexcept ValueError as e:\n    print(f'{e} — pass a bare command name'); sys.exit(2)","preventionTips":["Strip extensions with os.path.splitext before calling.","Pass allow_extensions=True when extensioned names are expected.","Remember this API takes command names, not file paths."],"tags":["python","valueerror","executable-lookup","arguments"],"backgroundTag":"invalid-argument-value","analyzedSha":"716bbc23d7eca949fdb682172283c8d18f742cb6","analyzedAt":"2026-08-28T21:57:47.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}