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

"mix test" doesn't work on Windows #281

Open
wingyplus opened this issue Jun 3, 2022 · 3 comments
Open

"mix test" doesn't work on Windows #281

wingyplus opened this issue Jun 3, 2022 · 3 comments
Labels
Effort:Large Kind:Help A question or request for help. Platform:Windows Windows-related issues.

Comments

@wingyplus
Copy link
Contributor

wingyplus commented Jun 3, 2022

If I run mix test on Windows, the project will raise error:

PS C:\Users\WingyMomo\src\github.com\elixir-protobuf\protobuf> mix test  
Generated protobuf app
Generated escript protoc-gen-elixir with MIX_ENV=test
Running: protoc --plugin=./protoc-gen-elixir --elixir_out="./generated" -I c:/Users/WingyMomo/src/github.com/elixir-protobuf/protobuf/deps/google_protobuf/src -I src -I test/protobuf/protoc/proto test/protobuf/protoc/proto/extension.proto
--elixir_out: protoc-gen-elixir: %1 is not a valid Win32 application.

** (Mix) Command exited with non-zero status: 1

After I investigate, I found that mix escript.build generate only unix shell script that run escript binary but not for Windows shell script. I try temporary by create protoc-gen-elixir.bat:

@echo off
@escript "%~dpn0" %*

NOTE: I copied this script from mix escript.install.

And modify mix.exs with:

diff --git a/mix.exs b/mix.exs
index 707526a..866b128 100644
--- a/mix.exs
+++ b/mix.exs
@@ -227,7 +227,7 @@ defmodule Protobuf.Mixfile do
     args =
       [
         ~s(protoc),
-        ~s(--plugin=./protoc-gen-elixir),
+        ~s(--plugin=./protoc-gen-elixir.bat),
         ~s(--elixir_out="#{elixir_out}"),
         args
       ] ++ files_to_generate

After run mix test will change to:

Generated protobuf app
Generated escript protoc-gen-elixir with MIX_ENV=test
Running: protoc --plugin=./protoc-gen-elixir.bat --elixir_out="./generated" -I c:/Users/WingyMomo/src/github.com/elixir-protobuf/protobuf/deps/google_protobuf/src -I src -I test/protobuf/protoc/proto test/protobuf/protoc/proto/extension.proto
** (Protobuf.DecodeError) cannot decode binary data, unknown wire type: 6
    (protobuf 0.10.1-dev) lib/protobuf/decoder.ex:80: Protobuf.Decoder.handle_field/5
    (protobuf 0.10.1-dev) lib/protobuf/decoder.ex:17: Protobuf.Decoder.decode/2
    (protobuf 0.10.1-dev) lib/protobuf/decoder.ex:231: Protobuf.Decoder.value_for_field/3
    (protobuf 0.10.1-dev) lib/protobuf/decoder.ex:382: Protobuf.Decoder.update_in_message/3
    (protobuf 0.10.1-dev) lib/protobuf/decoder.ex:176: Protobuf.Decoder.handle_value/6
    (protobuf 0.10.1-dev) lib/protobuf/decoder.ex:17: Protobuf.Decoder.decode/2
    (protobuf 0.10.1-dev) lib/protobuf/decoder.ex:231: Protobuf.Decoder.value_for_field/3
    (protobuf 0.10.1-dev) lib/protobuf/decoder.ex:382: Protobuf.Decoder.update_in_message/3
--elixir_out: protoc-gen-elixir: Plugin failed with status code 1.
** (Mix) Command exited with non-zero status: 1
@whatyouhide whatyouhide added the Platform:Windows Windows-related issues. label Jun 20, 2022
@whatyouhide
Copy link
Collaborator

@wingyplus I don't have a chance to test this since I don't have a Windows machine. Are you willing to give figuring this out a try? 🙃

@whatyouhide whatyouhide changed the title mix test doesn't work on Windows "mix test" doesn't work on Windows Jun 25, 2022
@wingyplus
Copy link
Contributor Author

wingyplus commented Jun 30, 2022

Just a little investigation. Inspecting rest inside decoder.ex with this diff:

diff --git a/lib/protobuf/decoder.ex b/lib/protobuf/decoder.ex
index 2fa107e..2febe12 100644
--- a/lib/protobuf/decoder.ex
+++ b/lib/protobuf/decoder.ex
@@ -42,6 +42,9 @@ defmodule Protobuf.Decoder do
     field_number = bsr(value, 3)
     wire_type = band(value, 0b00000111)
 
+    IO.inspect(:stderr, byte_size(rest), [])
+    IO.inspect(:stderr, rest, binaries: :as_binaries)
+
     if field_number != 0 do
       handle_field(rest, field_number, wire_type, message, props)
     else

This is the result when I'm running on Windows:

out.txt

@JohnDoneth
Copy link

I'm encountering the same issue and having a hard time tracking down where the issue could be during decoding.

value: 50
field_number: 6
wire_type: 2
bytes left: 62
<<46, 46, 103, 111, 111, 103, 108, 101, 46, 112, 114, 111, 116, 111, 98, 117,
  102, 46, 68, 101, 115, 99, 114, 105, 112, 116, 111, 114, 80, 114, 111, 116,
  111, 46, 82, 101, 115, 101, 114, 118, 101, 100, 82, 97, 110, 103, 101, 82, 10,
  114, 101, 115, 101, 114, 118, 101, 100, 82, 97, 110, 103, 101>>
---------------------------
value: 82
field_number: 10
wire_type: 2
bytes left: 14
<<10, 114, 101, 115, 101, 114, 118, 101, 100, 82, 97, 110, 103, 101>>
---------------------------
value: 110
field_number: 13
wire_type: 6
bytes left: 2
<<103, 101>>
** (Protobuf.DecodeError) cannot decode binary data, unknown wire type: 6
    (protobuf 0.12.0) lib/protobuf/decoder.ex:88: Protobuf.Decoder.handle_field/5
    (protobuf 0.12.0) lib/protobuf/decoder.ex:17: Protobuf.Decoder.decode/2

@whatyouhide whatyouhide added Kind:Help A question or request for help. Effort:Large labels May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Effort:Large Kind:Help A question or request for help. Platform:Windows Windows-related issues.
Projects
None yet
Development

No branches or pull requests

3 participants