microsoft / bond

Bond is a cross-platform framework for working with schematized data. It supports cross-language de/serialization and powerful generic mechanisms for efficiently manipulating data. Bond is broadly used at Microsoft in high scale services.
MIT License
2.61k stars 321 forks source link

"openFile: does not exist (No such file or directory)" on Linux #1183

Closed RussKie closed 1 year ago

RussKie commented 1 year ago

I'm getting the error "openFile: does not exist (No such file or directory)" when trying to run the build on a non-Windows build agent (Ubuntu).

$ ls bonddefaultcodegen.in -la
-rwxr-xr-x 1 user user 10 Mar  3 20:48 bonddefaultcodegen.in

$ cat bonddefaultcodegen.in 
Bond.bond
$ ~/.nuget/packages/bond.compiler.csharp/10.0.0/tools/gbc.exe c# --import-dir="~/.nuget/packages/bond.compiler.csharp/10.0.0/tools/inc/" --namespace=bond=Bond ./bonddefaultcodegen.in
gbc.exe: .\bonddefaultcodegen.in: openFile: does not exist (No such file or directory)

If I move the file into a subfolder, I get the following:

$ ~/.nuget/packages/bond.compiler.csharp/10.0.0/tools/gbc.exe c# --import-dir="~/.nuget/packages/bond.compiler.csharp/10.0.0/tools/inc/" --namespace=bond=Bond ./src/bonddefaultcodegen.in
gbc.exe: .\src\bonddefaultcodegen.in: openFile: does not exist (No such file or directory)

It looks to me as though the path is being converted into Windows path (i.e., "/" -> "\"), and this is probably what's causing the issue.

. . .

gbc.exe executes without obvious issues:

gbc.exe output ``` $ ~/.nuget/packages/bond.compiler.csharp/10.0.0/tools/gbc.exe Bond Compiler 0.12.1.0, (C) Microsoft gbc [COMMAND] ... [OPTIONS] Compile Bond schema file(s) and generate specified output. The schema file(s) can be in one of two formats: Bond IDL or JSON representation of the schema abstract syntax tree as produced by `gbc schema`. Multiple schema files can be specified either directly on the command line or by listing them in a text file passed to gbc via @listfile syntax. Common flags: -i --import-dir=DIR Add the directory to import search path -o --output-dir=DIR Output generated files into the specified directory -j --jobs[=NUM] Run NUM jobs simultaneously (or '$ncpus' if no NUM is not given) -? --help Display help message -V --version Print version information --numeric-version Print just the version number gbc c++ [OPTIONS] [FILE] Generate C++ code -u --using=MAPPING Custom type alias mapping in the form alias=type -n --namespace=MAPPING Custom namespace mapping in the form bond_namespace=language_namespace -h --header=HEADER Emit #include HEADER into the generated files -e --enum-header Generate enums into a separate header file --allocator=ALLOCATOR Generate types using the specified allocator --apply=PROTOCOL Generate Apply function overloads for the specified protocol only; supported protocols: compact, fast and simple --export-attribute=ATTRIBUTE --apply-attribute Prefix declarations for library export with the specified C++ attribute/declspec. apply-attribute is a deprecated synonym. --no-banner Omit the banner at the top of generated files --core Generate core serialization definitions (true by default, --core=false to disable) --grpc Generate gRPC definitions --alloc-ctors Generate constructors with allocator argument --type-aliases Generate type aliases --scoped-alloc Use std::scoped_allocator_adaptor for strings and containers --enable-service-inheritance Enable service inheritance syntax in IDL gbc c# [OPTIONS] [FILE] Generate C# code -u --using=MAPPING Custom type alias mapping in the form alias=type -n --namespace=MAPPING Custom namespace mapping in the form bond_namespace=language_namespace -c --collection-interfaces Use interfaces rather than concrete collection types -r --readonly-properties Generate private property setters -f --fields Generate public fields rather than properties --no-banner Omit the banner at the top of generated files --structs Generate C# types for Bond structs and enums (true by default, use "--structs=false" to disable) --grpc Generate C# services and proxies for gRPC --enable-service-inheritance Enable service inheritance syntax in IDL --preview-constructor-parameters PREVIEW FEATURE: Generate a constructor that takes all the fields as parameters. Typically used with readonly-properties. gbc java [OPTIONS] [FILE] Generate Java code -u --using=MAPPING Currently unimplemented and ignored for Java -n --namespace=MAPPING Custom namespace mapping in the form bond_namespace=language_namespace --no-banner Omit the banner at the top of generated files gbc schema [OPTIONS] [FILE] Output the JSON representation of the schema -r --runtime-schema Generate Simple JSON representation of runtime schema, aka SchemaDef --enable-service-inheritance Enable service inheritance syntax in IDL ```
chwarr commented 1 year ago

I don't understand how you even got this far running gbc.exe on a Linux host. :-) The gbc.exe in the NuGet package is an Windows binary. I would expect invoking that gbc.exe to fail with an error about the file being non-executable or in a bad format. Are you using Wine or something like it?

RussKie commented 1 year ago

I don't understand how you even got this far running gbc.exe on a Linux host. :-) The gbc.exe in the NuGet package is an Windows binary. I would expect invoking that gbc.exe to fail with an error about the file being non-executable or in a bad format. Are you using Wine or something like it?

I was surprised as well :) I've run it locally under wsl2, I have no idea what makes that tick...

I went and studied build log from an Ubuntu build agent, and I think you're right - it didn't work there at all:

  /usr/bin/sh: 2: /tmp/MSBuildTempcloudtest/tmpd8b95f3859a5437f9e9a945de90024e6.exec.cmd: /mnt/vss/_work/1/s/.packages/bond.compiler.csharp/10.0.0/build/netstandard1.6/../../tools/gbc.exe: Exec format error
/mnt/vss/_work/1/s/.packages/bond.compiler.csharp/10.0.0/build/netstandard1.6/Common.targets(161,5): error MSB3073: The command ""/mnt/vss/_work/1/s/.packages/bond.compiler.csharp/10.0.0/build/netstandard1.6/../../tools/gbc.exe" c# --import-dir="/mnt/vss/_work/1/s/.packages/bond.compiler.csharp/10.0.0/build/netstandard1.6/../../tools/inc"  --jobs=-2 --namespace=bond=Bond --output-dir="/mnt/vss/_work/1/s/artifacts/obj/PerformanceTests/Release/net8.0/"  @"/mnt/vss/_work/1/s/artifacts/obj/PerformanceTests/Release/net8.0/bonddefaultcodegen.in"" exited with code 126. [/mnt/vss/_work/1/s/bench/Extensions/PerformanceTests/PerformanceTests.csproj]
##[error].packages/bond.compiler.csharp/10.0.0/build/netstandard1.6/Common.targets(161,5): error MSB3073: (NETCORE_ENGINEERING_TELEMETRY=Build) The command ""/mnt/vss/_work/1/s/.packages/bond.compiler.csharp/10.0.0/build/netstandard1.6/../../tools/gbc.exe" c# --import-dir="/mnt/vss/_work/1/s/.packages/bond.compiler.csharp/10.0.0/build/netstandard1.6/../../tools/inc"  --jobs=-2 --namespace=bond=Bond --output-dir="/mnt/vss/_work/1/s/artifacts/obj/PerformanceTests/Release/net8.0/"  @"/mnt/vss/_work/1/s/artifacts/obj/PerformanceTests/Release/net8.0/bonddefaultcodegen.in"" exited with code 126.

It's just the first line isn't highlighted/reported as error, which made it easy to miss.

mbslimane commented 2 months ago

you are using ".\" instead of "./"