Skip to content

Commit

Permalink
"open" support for experimental-explorer on Linux (pantsbuild#21574)
Browse files Browse the repository at this point in the history
`open` isn't a traditional Linux command, but
[xdg-open](https://wiki.archlinux.org/title/Default_applications) is a
common part of many distros and exits to "open a file or URL in the
user's preferred application".

NOTE: The intend here is limited to make experimental-explorer runnable
without crashing on Linux, I have not done any testing of how various
GUI applications work or not when invoked from the sandbox.
  • Loading branch information
cburroughs authored Nov 5, 2024
1 parent fdfd8d2 commit cc01848
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/python/pants/core/util_rules/system_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,13 @@ async def find_mv(system_binaries: SystemBinariesSubsystem.EnvironmentAware) ->


@rule(desc="Finding the `open` binary", level=LogLevel.DEBUG)
async def find_open(system_binaries: SystemBinariesSubsystem.EnvironmentAware) -> OpenBinary:
request = BinaryPathRequest(binary_name="open", search_path=system_binaries.system_binary_paths)
async def find_open(
platform: Platform, system_binaries: SystemBinariesSubsystem.EnvironmentAware
) -> OpenBinary:
request = BinaryPathRequest(
binary_name=("open" if platform.is_macos else "xdg-open"),
search_path=system_binaries.system_binary_paths,
)
paths = await Get(BinaryPaths, BinaryPathRequest, request)
first_path = paths.first_path_or_raise(request, rationale="open URLs with default browser")
return OpenBinary(first_path.path, first_path.fingerprint)
Expand Down

0 comments on commit cc01848

Please sign in to comment.