question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Space in path causes ClassParse to fail

See original GitHub issue

Description

When trying to compile a Jar project for Android the compilation fails when the path contains a space. It gives the following output:

1>Building target "_ExportJarToXml" completely.
1>Output file "<mypath>\Release\api.xml" does not exist.
1>Using "ClassParse" task from assembly "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\Xamarin.Android.Build.Tasks.dll".
1>Task "ClassParse"
1>  Using: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\class-parse.exe
1>  [class-parse] response file: <mypath>\Release\class-parse.rsp
1>  --o="<mypath>\Release\api.xml.class-parse"
1>  "Jars\IOIOLibCore-5.07.jar"
1>  C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\class-parse.exe @<mypath>\Release\class-parse.rsp 
1>  
1>  Unhandled Exception: System.IO.FileNotFoundException: Could not find file '<my path left of first space>'.
1>     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
1>     at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
1>     at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
1>     at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
1>     at System.IO.StreamReader..ctor(String path)
1>     at System.IO.File.OpenText(String path)
1>     at Mono.Options.ResponseFileSource.GetArguments(String value, IEnumerable`1& replacement) in D:\a\1\s\XPlat\Mono.Options\externals\Options.cs:line 718
1>     at Mono.Options.OptionSet.AddSource(ArgumentEnumerator ae, String argument) in D:\a\1\s\XPlat\Mono.Options\externals\Options.cs:line 1094
1>     at Mono.Options.OptionSet.Parse(IEnumerable`1 arguments) in D:\a\1\s\XPlat\Mono.Options\externals\Options.cs:line 1050
1>     at Xamarin.Android.Tools.App.Main(String[] args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/tools/class-parse/Program.cs:line 61
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.ClassParse.targets(30,5): error MSB6006: "class-parse.exe" exited with code -532462766.
1>Done executing task "ClassParse" -- FAILED.
1>Done building target "_ExportJarToXml" in project "IOIOLibJar.csproj" -- FAILED.

If I run the command given below from the project directory then it doesn’t show an error message, and a api.xml.class-parse exists in the obj folder. Note the added quotes for the command line parameter.

"C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\class-parse.exe" "@<mypath>\Release\class-parse.rsp"

Unfortunately, running this command manually does not enable building because the xml file needs to be processed to generate api.xml.

Steps to Reproduce

  1. Copy a jar project to a directory which contains a space in the path.
  2. Rebuild the project with Visual Studio

Visual Studio version 17.3 Preview 1.1 .NET 6.0.301

Version with bug

Unknown/Other (please specify)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android (All)

Did you find any workaround?

No response

Relevant log output

1>Building target "_ExportJarToXml" completely.
1>Output file "<mypath>\Release\api.xml" does not exist.
1>Using "ClassParse" task from assembly "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\Xamarin.Android.Build.Tasks.dll".
1>Task "ClassParse"
1>  Using: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\class-parse.exe
1>  [class-parse] response file: <mypath>\Release\class-parse.rsp
1>  --o="<mypath>\Release\api.xml.class-parse"
1>  "Jars\IOIOLibCore-5.07.jar"
1>  C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\class-parse.exe @<mypath>\Release\class-parse.rsp 
1>  
1>  Unhandled Exception: System.IO.FileNotFoundException: Could not find file '<my path left of first space>'.
1>     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
1>     at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
1>     at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
1>     at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
1>     at System.IO.StreamReader..ctor(String path)
1>     at System.IO.File.OpenText(String path)
1>     at Mono.Options.ResponseFileSource.GetArguments(String value, IEnumerable`1& replacement) in D:\a\1\s\XPlat\Mono.Options\externals\Options.cs:line 718
1>     at Mono.Options.OptionSet.AddSource(ArgumentEnumerator ae, String argument) in D:\a\1\s\XPlat\Mono.Options\externals\Options.cs:line 1094
1>     at Mono.Options.OptionSet.Parse(IEnumerable`1 arguments) in D:\a\1\s\XPlat\Mono.Options\externals\Options.cs:line 1050
1>     at Xamarin.Android.Tools.App.Main(String[] args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/tools/class-parse/Program.cs:line 61
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.ClassParse.targets(30,5): error MSB6006: "class-parse.exe" exited with code -532462766.
1>Done executing task "ClassParse" -- FAILED.
1>Done building target "_ExportJarToXml" in project "IOIOLibJar.csproj" -- FAILED.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
HermanElderingcommented, Jun 16, 2022

@jpobst I’ve noticed the same issue in the GenerateBindings target. It was also fixed in the commit you’ve linked. Just thought I’d point that before you separate out changes for this issue. See src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs at line 239/240.

1reaction
jpobstcommented, Jun 15, 2022

Probably, I guess this doesn’t automatically quote arguments:

cmd.AppendSwitch ($"@{responseFile}");

I can fix this week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

git commands fail with spaces in path
This is a bug in Windows. Windows does not normally permit trailing spaces in a directory or file name. This isn't a limitation...
Read more >
Space in path causes error - Development Platforms
Hello,. I've recently bought an arduino but I really wasn't happy about the default IDE, so I searched and found PlatformIO (installed on ......
Read more >
Spaces in Paths - %20 Weirdness
Whenever the application tries to use File objects to hold paths that have spaces in them, it appears that the spaces *magically* become...
Read more >
How to resolve the error "Path cannot have a space after ...
This error "Path cannot have space after a slash" would occur during the Debian metadata indexing if there is any space in the...
Read more >
White-space in file path causes error when installing ...
My windows username is my real name with a whitespace between. From R 3.6.2 (I think) onwards, this has been an issue with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found