{"record":{"id":"dae75c0937ec5cf9","repo":"apache/beam","slug":"the-file-s-cannot-be-found-it-was-specified-in-the","errorCode":null,"errorMessage":"The file %s cannot be found. It was specified in the --requirements_file command line option.","messagePattern":"The file (.+?) cannot be found\\. It was specified in the --requirements_file command line option\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/runners/portability/stager.py","lineNumber":236,"sourceCode":"\n    # We can skip boot dependencies: apache beam sdk, python packages from\n    # requirements.txt, python packages from extra_packages and workflow tarball\n    # if we know we are using a dependency pre-installed sdk container image.\n    if not skip_prestaged_dependencies:\n      requirements_cache_path = (\n          os.path.join(tempfile.gettempdir(), 'beam-requirements-cache') if\n          (setup_options.requirements_cache\n           is None) else setup_options.requirements_cache)\n      if (setup_options.requirements_cache != SKIP_REQUIREMENTS_CACHE and\n          not os.path.exists(requirements_cache_path)):\n        os.makedirs(requirements_cache_path, exist_ok=True)\n\n      # Track packages to stage for this specific run.\n      packages_to_stage = set()\n      # Stage a requirements file if present.\n      if setup_options.requirements_file is not None:\n        if not os.path.isfile(setup_options.requirements_file):\n          raise RuntimeError(\n              'The file %s cannot be found. It was specified in the '\n              '--requirements_file command line option.' %\n              setup_options.requirements_file)\n        extra_packages, thinned_requirements_file = (\n            Stager._extract_local_packages(setup_options.requirements_file))\n        if extra_packages:\n          setup_options.extra_packages = (\n              setup_options.extra_packages or []) + extra_packages\n        resources.append(\n            Stager._create_file_stage_to_artifact(\n                thinned_requirements_file, REQUIREMENTS_FILE))\n        # Populate cache with packages from the requirement file option and\n        # stage the files in the cache.\n        if not use_beam_default_container:\n          _LOGGER.warning(\n              'When using a custom container image, prefer installing'\n              ' additional PyPI dependencies directly into the image,'\n              ' instead of specifying them via runtime options, '","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/runners/portability/stager.py#L218-L254","documentation":"Stager.create_job_resources stages a user's pip requirements file for worker environments. If setup_options.requirements_file is set but the path is not an existing file at staging time, Beam raises RuntimeError naming the file and pointing back to the --requirements_file option.","triggerScenarios":"--requirements_file=/path/reqs.txt passed on the CLI (or requirements_file set in SetupOptions) while the file does not exist relative to the working directory of the submitting process — checked with os.path.isfile before staging.","commonSituations":"Relative path resolved from a different CWD (CI vs local); file deleted between authoring and launch; typo in filename; container/remote submission where the file wasn't mounted or copied.","solutions":["Correct the --requirements_file path (use an absolute path) and ensure the file exists before launching.","cd to the expected directory or fix the relative path used by the submitting process.","In CI/containers, mount or copy the requirements file into the submitter's filesystem before running the pipeline.","Pre-validate with os.path.isfile(requirements_file) in your launcher script to fail fast with a clearer message."],"exampleFix":"// before\n--requirements_file=requirements.txt   # not in CWD\n// after\n--requirements_file=$(pwd)/requirements.txt","handlingStrategy":"validation","validationCode":"import os\nreq = setup_options.requirements_file\nif req is not None and not os.path.isfile(os.path.abspath(req)):\n    raise SystemExit(f'--requirements_file not found: {os.path.abspath(req)}')","typeGuard":null,"tryCatchPattern":"try:\n    Stager.create_and_stage_job_resources(options, tmpdir)\nexcept RuntimeError as e:\n    if 'cannot be found' in str(e) and 'requirements_file' in str(e):\n        print('Check --requirements_file path; use an absolute path')\n        sys.exit(2)\n    raise","preventionTips":["Pass absolute paths for --requirements_file","Run the submitter from a known CWD or resolve paths at launch","In CI, assert the requirements file exists before the pipeline step"],"tags":["apache-beam","staging","pip","file"],"backgroundTag":"file-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}