{"record":{"id":"82277956057521f7","repo":"google/python-fire","slug":"findexecutableonpath-0-failed-because-first-822779","errorCode":null,"errorMessage":"FindExecutableOnPath({0},...) failed because first argument must not have a path.","messagePattern":"FindExecutableOnPath\\((.+?),\\.\\.\\.\\) failed because first argument must not have a path\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"fire/console/files.py","lineNumber":102,"sourceCode":"      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":84,"sourceCodeEnd":115,"githubUrl":"https://github.com/google/python-fire/blob/716bbc23d7eca949fdb682172283c8d18f742cb6/fire/console/files.py#L84-L115","documentation":"FindExecutableOnPath only resolves bare executable names against PATH directories; if the first argument contains a directory component (os.path.dirname is non-empty), it raises ValueError because PATH search semantics do not apply to relative/absolute paths. Paths should be checked for existence directly instead.","triggerScenarios":"FindExecutableOnPath('/usr/bin/git') or FindExecutableOnPath('./tools/git') — any executable argument containing '/' or a drive/directory prefix.","commonSituations":"Users copying a full path where the API expects a name; conflating PATH lookup with local file resolution; building commands from config that stores full paths.","solutions":["Pass only the executable name: FindExecutableOnPath('git').","If you already have a full path, use os.path.exists/shutil.which on it directly instead of this function.","Split off the directory and search only the basename if PATH resolution is genuinely needed."],"exampleFix":"// before\nFindExecutableOnPath('/usr/bin/git')\n// after\nif os.path.exists('/usr/bin/git'): use('/usr/bin/git')\nelse: exe = FindExecutableOnPath('git')","handlingStrategy":"validation","validationCode":"import os\nif os.path.dirname(executable):\n    if os.path.exists(executable):\n        resolved = executable  # use directly, skip PATH search\n    else:\n        raise SystemExit(f'not found: {executable}')","typeGuard":"def is_bare_name(name: str) -> bool:\n    return os.path.dirname(name) == ''","tryCatchPattern":"try:\n    exe = files.FindExecutableOnPath(executable)\nexcept ValueError as e:\n    print(f'{e} — pass a name without directory components'); sys.exit(2)","preventionTips":["Pass only the executable name; let the function search PATH.","For explicit paths, check os.path.exists or use shutil.which yourself.","Keep full paths and bare names in separate config fields."],"tags":["python","valueerror","executable-lookup","path"],"backgroundTag":"invalid-argument-value","analyzedSha":"716bbc23d7eca949fdb682172283c8d18f742cb6","analyzedAt":"2026-08-28T21:57:47.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}