Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build.bazel.remote.execution.v2.Command.arguments[0] should specify a path separator. #187

Open
rubensf opened this issue Mar 9, 2021 · 5 comments

Comments

@rubensf
Copy link
Contributor

rubensf commented Mar 9, 2021

Motivation: bazelbuild/bazel#11636 (comment)

Throughout the API, both for inputs (in SymlinkNodes) and in outputs, we specify that separators should be single forward slashes (/). However, we're not explicit on the Command arguments, which currently reads:

  // The arguments to the command. The first argument must be the path to the
  // executable, which must be either a relative path, in which case it is
  // evaluated with respect to the input root, or an absolute path.
repeated string arguments = 1;

The issue here comes from Windows cmd.exe not being able to naively recognize relative paths using / separators as executables, eg:

(cmd) $ foo/bar.bat
'foo' is not recognized as an internal or external command, operable program or batch file.

While there are many ways for the server to go around that restrictions (eg converting / -> \, wrapping the command in quotes, etc), we should it explicit whose responsibility it is to deal with this:

  1. The server can responsible to process the path according to the executing platform;
  2. The client can be responsible to ensure that argument[0] is executable without any additional processing;
  3. We could specify that the separator should be the platform's default;
  4. Technically, we could make it that either / or \ are valid, though I find little benefit to this approach, as it's a more ambiguous than 1 but forces the server to apply processing anyway (and maybe there exists a bizarre scenario where both are valid and yield different results?)

I'm personally prefer 1. as the server may be already doing other processing on the command and figuring out the platform specific separator shouldn't be challenging, but I don't have a strong preference here as the approach is explicitly stated.

@EdSchouten
Copy link
Collaborator

I think that solution 2 is the only logical one. Solution 1 would only make sense if you only call into programs inside the input root. It’s perfectly valid to also call into programs installed on the system: C:\Program Files\foo. Using forward slashes there would be really weird.

Furthermore, this problem also applies to successive arguments. Those most likely need backslashes as well. It would be inconsistent if argv[0]’s conventions differ from the rest.

@EricBurnett
Copy link
Collaborator

EricBurnett commented Mar 9, 2021 via email

@bergsieker
Copy link
Collaborator

bergsieker commented Mar 9, 2021 via email

@rubensf
Copy link
Contributor Author

rubensf commented Mar 12, 2021

I intended option 1 to apply exclusively to argv[0], since it should always (?) be a non-path separated function or command in the $PATH, or be the canonical path to an executable.

Maybe it also makes sense to define some reasonable entry point on the server side? The user or the server could have weird setups (eg a user specified docker container with a cygwin bash entrypoint) that might be incompatible with the OS default (eg cygwin). It'd be unreasonable for bazel as a client tool to make those assumptions?

@ulfjack
Copy link
Collaborator

ulfjack commented Feb 8, 2022

The client also specifies the docker container, and that should allow it to make assumptions about the contents thereof.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants