-
Notifications
You must be signed in to change notification settings - Fork 18k
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
x/tools/go/packages: document role of PWD in DriverRequest protocol #67757
Comments
Per discussion, setting PWD correctly when using os/exec is likely the right solution here rather than adding new API. |
And the way to set |
FWIW,
I realize that the odds of the driver program being in a language other than Go are low, but I don't think this interface should assume anything about the implementation language of the child process or require it to know that it should use |
The C library function that looks at Checking If we set |
FWIW, that's a GNUism rather than a standard feature of C, and I don't think I ever used it (or was much aware of it, or the motivating subtlety) when I was working in C/C++. But perhaps you're right that there is a convention.
Not at present. Perhaps this can be downgraded to a documentation issue. I think there are two aspects:
|
Retracting the proposed change; leaving the issue open until item 2 in the previous note is addressed. |
Change https://go.dev/cl/616057 mentions this issue: |
Original title: x/tools/go/packages: add DriverRequest.Dir string
(Proposal withdrawn; this is now a doc issue.)
The go/packages driver protocol runs an external command in place of
go list
to retrieve Go package metadata from the build system, whatever it is. It has hitherto always implicitly assumed that the name of the directory in which the command is run will be used to absolutize any relative file names generated by the command. However, creating a process loses information about the directory name: the string is lost, only the inode is retained by the process. (Confusing matters, there is a special-case heuristic when $PWD exactly matches--not prefix-matches--the directory... though happily it can be used as the basis of a work-around.) Consequently, the string returned by Go's os.Getwd or C's getcwd(3) within the child process may differ from the original string, and this difference is crucial, since the returned filenames will not satisfy the original query.We propose to add an explicit
Dir string
field to theDriverRequest
struct to be used for path absolutization.(Context: https://go.dev/cl/588767)
@findleyr
The text was updated successfully, but these errors were encountered: