<#19375 Bash is not guaranteed to be in hardcoded ...
# github-notifications
c
#19375 Bash is not guaranteed to be in hardcoded search paths Issue created by grxnola Pants can fail to find Bash on POSIX-compatible systems because of the hardcoded search paths it uses to locate the binary. Bash is not guaranteed to be in any of these directories. I would hope Pants can instead respect the PATH in the inherited environment variables (or provide some way to configure this) and consider bash unavailable if not found (or fall back to hardcoded paths first). The search paths are hardcoded here. Following is an example shell session with pants output: ``` [dch@cognac:~/src/pants]$ PY=python3.9 ./pants run src/python/pants_release/release.py -ldebug -- build-local-pex 163215.08 [DEBUG] Connected to pantsd 163215.08 [DEBUG] work dir: /home/dch/src/pants 163215.11 [DEBUG] Launching 1 roots (poll=false). 163215.15 [DEBUG] computed 1 nodes in 0.034359 seconds. there are 41 total nodes. 163215.15 [DEBUG] Launching 1 roots (poll=false). 163215.15 [DEBUG] Starting: Finding the
bash
binary 163215.15 [DEBUG] Starting: Prepare environment for running PEXes 163215.15 [DEBUG] Starting: pants.core.util_rules.search_paths.validate_search_paths 163215.15 [DEBUG] Completed: pants.core.util_rules.search_paths.validate_search_paths 163215.15 [DEBUG] Starting: Scheduling: Searching for
bash
on PATH=/usr/bin/bin/usr/local/bin 163215.15 [DEBUG] Starting: acquire_command_runner_slot 163215.15 [DEBUG] Completed: acquire_command_runner_slot 163215.15 [DEBUG] Running Searching for
bash
on PATH=/usr/bin/bin/usr/local/bin under semaphore with concurrency id: 1, and concurrency: 1 163215.15 [DEBUG] Starting: Searching for
bash
on PATH=/usr/bin/bin/usr/local/bin 163215.15 [DEBUG] Starting: setup_sandbox 163215.15 [DEBUG] Completed: setup_sandbox 163215.16 [DEBUG] Completed: Prepare environment for running PEXes 163215.16 [DEBUG] spawned local process as Some(1291157) for Process { argv: ["./find_binary.sh", "bash"], env: {"PATH": "/usr/bin/bin/usr/local/bin"}, working_directory: None, input_digests: InputDigests { complete: DirectoryDigest { digest: Digest { hash: Fingerprint<fc33a6ab65993fa57d52edbff44d8a8a89faa2ec0669950d238b481da5caf15c>, size_bytes: 91 }, tree: "Some(..)" }, nailgun: DirectoryDigest { digest: Digest { hash: Fingerprint<e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, size_bytes: 0 }, tree: "Some(..)" }, inputs: DirectoryDigest { digest: Digest { hash: Fingerprint<fc33a6ab65993fa57d52edbff44d8a8a89faa2ec0669950d238b481da5caf15c>, size_bytes: 91 }, tree: "Some(..)" }, immutable_inputs: {}, use_nailgun: {} }, output_files: {}, output_directories: {}, timeout: None, execution_slot_variable: None, concurrency_available: 0, description: "Searching for
bash
on PATH=/usr/bin/bin/usr/local/bin", level: Debug, append_only_caches: {}, jdk_home: None, cache_scope: PerRestartSuccessful, execution_environment: ProcessExecutionEnvironment { name: None, platform: Linux_x86_64, strategy: Local }, remote_cache_speculation_delay: 0ns } 163215.16 [DEBUG] Completed: Searching for
bash
on PATH=/usr/bin/bin/usr/local/bin 163215.16 [DEBUG] Completed: Scheduling: Searching for
bash
on PATH=/usr/bin/bin/usr/local/bin 163215.16 [DEBUG] Completed: Finding the
bash
binary 163215.16 [DEBUG] computed 1 nodes in 0.015189 seconds. there are 76 total nodes. 163215.16 [ERROR] 1 Exception encountered: Engine traceback: in select .. in pants.init.plugin_resolver.resolve_plugins .. Traceback (most recent call last): File "/home/dch/src/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send res = rule.send(arg) if err is None else rule.throw(throw or err) File "/home/dch/src/pants/src/python/pants/init/plugin_resolver.py", line 74, in resolve_plugins plugins_pex = await Get( File "/home/dch/src/pants/src/python/pants/engine/internals/selectors.py", line 118, in await result = yield self File "/home/dch/src/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send res = rule.send(arg) if err is None else rule.throw(throw or err) File "/home/dch/src/pants/src/python/pants/core/util_rules/system_binaries.py", line 453, in get_bash paths = await Get(BinaryPaths, BinaryPathRequest, request) File "/home/dch/src/pants/src/python/pants/engine/internals/selectors.py", line 118, in await result = yield self File "/home/dch/src/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send res = rule.send(arg) if err is None else rule.throw(throw or err) File "/home/dch/src/pants/src/python/pants/core/util_rules/system_binaries.py", line 513, in find_binary result = await Get( File "/home/dch/src/pants/src/python/pants/engine/internals/selectors.py", line 118, in await result = yield self pants.engine.process.ProcessExecutionFailure: Process 'Searching for
bash
on PATH=/usr/bin/bin/usr/local/bin' failed with exit code 127. stdout: stderr: /usr/bin/env: 'bash': No such file or directory Use
--keep-sandboxes=on_failure
to preserve the process chroot for inspection. Traceback (most recent call last): File "/home/dch/src/pants/src/python/pants/bin/daemon_pants_runner.py", line 133, in single_daemonized_run scheduler, options_initializer = self._core.prepare(options_bootstrapper, complete_env) File "/home/dch/src/pants/src/python/pants/pantsd/pants_daemon_core.py", line 130, in prepare build_config = self._options_initializer.build_config(options_bootstrapper, env) File "/home/dch/src/pants/src/python/pants/init/options_initializer.py", line 111, in build_config return _initialize_build_configuration(self._plugin_resolver, options_bootstrapper, env) File "/home/dch/src/pants/src/python/pants/init/options_initializer.py", line 48, in _initialize_build_configuration working_set = plugin_resolver.resolve(options_bootstrapper, env) File "/home/dch/src/pants/src/python/pants/init/plugin_resolver.py", line 133, in resolve for resolved_plugin_location in self._resolve_plugins( File "/home/dch/src/pants/src/python/pants/init/plugin_resolver.py", line 160, in _resolve_plugins session.product_request(ResolvedPluginDistributions, [params])[0], File "/home/dch/src/pants/src/python/pants/engine/internals/scheduler.py", line 579, in product_request return self.execute(request) File "/home/dch/src/pants/src/python/pants/engine/internals/scheduler.py", line 520, in execute self._raise_on_error([t for _, t in throws]) File "/home/dch/src/pants/src/python/pants/engine/internals/scheduler.py", line 504, in _raise_on_error raise ExecutionError( pants.engine.internals.scheduler.ExecutionError: 1 Exception encountered: Engine traceback: in select .. in pants.init.plugin_resolver.resolve_plugins .. Traceback (most recent call last): File "/home/dch/src/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send res = rule.send(arg) if err is None else rule.throw(throw or err) File "/home/dch/src/pants/src/python/pants/init/plugin_resolver.py", line 74, in resolve_plugins plugins_pex = await Get( File "/home/dch/src/pants/src/python/pants/engine/internals/selectors.py", line 118, in await result = yield self File "/home/dch/src/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send res = rule.send(arg) if err is None else rule.throw(throw or err) File "/home/dch/src/pants/src/python/pants/core/util_rules/system_binaries.py", line 453, in get_bash paths = await Get(BinaryPaths, BinaryPathRequest, request) File "/home/dch/src/pants/src/python/pants/engine/internals/selectors.py", line 118, in await result = yield self File "/home/dch/src/pants/src/python/pants/engi… pantsbuild/pants