-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Grpc.Tools: Accented characters in nuget path breaks c# grpc tool compiler #17995
Comments
Thanks, the repro seems clear. In the command line message that you copy, there is no final quote at the very end of the command. Is this what you are actually seeing, or did it just not make it when copying? I'll have a look at this, indeed, but, in all fairness, when working with tools originally designed for Linux and ported to Windows later, is it really important to push them to the limit and use paths with spaces and Unicode characters? I am just trying to estimate how to prioritize this issue. As a workaround, a symlink (or NTFS junction) e. g. |
@kkm000 are you planning to come up with a fix? |
@jtattermusch, is this worth it? What is your feeling? |
I'd say not supporting spaces in file names is bad. About not supporting accented characters I feel less strongly, but also something that should really work. How much work is it to fix this? |
@jtattermusch, ok, let me have a look. I agree, paths should be quoted everywhere, so spaces must work. The non-ASCII, if an issue, then it's likely in the tools, as .NET is all wchar_t throughout. I have quite a batch of issues already, should be able to get to them this week. |
I think the rootcause for not handling spaces in filenames correctly is the same as in #17661 (the CsharpGeneratorService doesn't mimic |
Sorry @ludydoo, it looks like we cannot fix that. This has to do with the way protoc handles non-ASCII characters. First, I reproduce your issue, right in the grpc tree (some output trimmed for brevity; the environment variable
The command as reported in the log fails in a different manner, but this has to do with the way arguments are passed to protoc (more on that later):
Note the Really the arguments are passed using a response file, since protoc accepts spaces in arguments, one per line, without quoting. Let's construct this file, protoc.rsp, save as UTF-8:
and give it a go with protoc
Now the build error reproduces exactly. protoc complains now that it cannot find the file specified in To confirm that the issue is not with the space in the path, do
protoc accepts spaces either on command line, if quoted as logged (I'm using the same executable path; Windows itself is ok with this):
Or in the response file
again saved as protoc.rsp:
TL;DR: This is a issue with non-ASCII character in paths, not spaces, and the bug is in protoc, not in gRPC tooling. I believe that fixing it to support Windows filenames properly would be difficult. @jtattermusch, what is your take on this, what do you think? |
Looks like the problem with spaces might be at least partially fixed by #18470? (if the space is in the name of the '.proto' file itself, not the path) |
@jtattermusch, the problem is not with spaces, but rather with the way protoc's handles non-ASCII characters. This reproduces with protoc from command line. So no, this won't help, that's a different issue. I have no idea how eager is the protoc team about filing off the corners of the Windows port. There must be an additional, OS-specific layer that does the conversion between OS an ind internal path representation. Besides path syntax, even encoding differs: Windows API use wchar_t representing codepoints (not UTF-16), while protoc uses UTF-8 MBC internally. |
This issue/PR has been automatically marked as stale because it has not had any update (including commits, comments, labels, milestones, etc) for 180 days. It will be closed automatically if no further update occurs in 1 day. Thank you for your contributions! |
Still an issue. |
Still an issue for me too.
|
@kkm000 can you provide a simple repro of the |
just shit!!!!!!! bugs fly everywhere!! |
As a workaround: I would like this to get fixed though. related: |
@Falco20019 would you be interested in picking this issue up, since you already have some experience with Grpc.Tools internals? |
@jtattermusch The problem lies partly within test.rsp:
Cmd: As soon as a non-ASCII character is in the RSP file, it does fail. And UTF-16 characters also seem to fail in EDIT: I found a way to change how we encode the response file here: According to dotnet/msbuild#4904 this should work on MSBuild 16.5. Sadly, |
I thought about it some more tonight. I found the command „chcp“ to change the codepage. Powershell seems to support UTF-32, so maybe after setting it together with the encoding in our code, protoc because able to support those characters. I assume that the processor was just using system default encoding (1252) and tried to interpret the UTF-8 with it. Will try it out later. |
@jtattermusch I think I have a clearer picture of the problem now. https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/command_line_interface.cc#L1326 reads the file using We should use |
@Falco20019 interesting findings. grpc/src/csharp/Grpc.Tools/ProtoCompile.cs Line 414 in db932d8
A quick documentation check also reveals that there is |
@jtattermusch Should also be possible, but then we would need to do escaping (start/end of arguments) ourselves. I will give it a look. |
So if I give my full name when I install Windows and then I install VS 2019 I am going to have a global-packages folder with spaces - because I have a first and a last names delimited by spaces, and the default global packages folder is under my user folder. Then I create a grpcService project and try to build it, I will get this error. Because this is what I did. Don't you think it would be worth at least documenting the workaround step by step (for a year old issue that has not been solved)? Or is it only me with a first name and last name who tries to use grpc? |
@danielleiszen I'm just trying out the approach using |
@danielleiszen It seems like this change will help with any UTF-8 chracters and also whitepaces, but will not fix problems for UTF-16 users. As of my current understanding of the |
Just ran into this problem as well with my username being unchangeable (and 'azuread\jörg' .. with an umlaut) as it is set via Azure AD. |
@joergbattermann #22916 should fix this for you once merged as german umlauts are fine with UTF-8. I will try and ping Jan on that. I might need to rebase the PR. |
I just ran into this issue as well, either due to a space or the 'ã' character in my name from the windows user folder. |
@JoaoPinheiro Feel free to ping #22916 as it's implemented but not merged. |
@krishna116 The root cause is protocolbuffers/protobuf#7474 which needs to be solved on protoc. |
Summarising the discussion for my benefit (and anyone else revisiting this):
Some notes on a possible Looking at the protobuf code, the fix isn't changing from io_win32.cc seems to handle conversion from utf8 to The problem seems to be when calling the plugins in subprocess.cc. |
protocolbuffers/protobuf#10200 was merged, which should fix this problem once
|
I'm going to close this issue now, let's update this thread once the fix is released as part of Grpc.Tools (see #17995 (comment) for details). |
I'm still experiencing this in Grpc.Tools 2.51.0. Is that expected? |
@kimjamia A release hasn't yet happened that contains the fix. |
#32136 upgrades our third_party/protobuf dependency to 21.12, which does contain the fix from protocolbuffers/protobuf#10200. |
@kkm000
1.18.0. C#
Windows 10 Pro x64
Reproduce :
What did you expect to see?
Successful build
What did you see instead?
--grpc_out could not find the path specified
"C:\Users\Dré Lot\.nuget\packages\grpc.tools\1.18.0\tools\windows_x64\protoc.exe" --proto_path="C:\Repositories\MyRepo" --grpc_out="C:\Repositories\MyRepo\MyRepo.Server" --plugin=protoc-gen-grpc="C:\Users\Dré Lot\.nuget\packages\grpc.tools\1.18.0\tools\windows_x64\grpc_csharp_plugin.exe" "C:\Repositories\MyRepo\MyRepo\book.proto
This is what the Task executes. If I run this myself in a cmd, it works. For some reason, the task itself fails with --grpc-out The path specified could not be found
The text was updated successfully, but these errors were encountered: