_CompileJava Exception: System.IO.IOException: Too many open files

One one our teams Branches, we seem to be running into an issue building with Bitrise:

“/Users/vagrant/git/Test.Android/Test.Android.csproj” (SignAndroidPackage target) (1) ->
(_CompileJava target) ->
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2034,3): error MSB4018: The “Javac” task failed unexpectedly. [/Users/vagrant/git/Test.Android/Test.Android.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2034,3): error MSB4018: System.IO.IOException: Too many open files [/Users/vagrant/git/Test.Android/Test.Android.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2034,3): error MSB4018: at System.IO.Directory.InsecureGetCurrentDirectory () [0x00010] in :0 [/Users/vagrant/git/Test.Android/Test.Android.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2034,3): error MSB4018: at System.IO.Path.InsecureGetFullPath (System.String path) [0x0010f] in :0 [/Users/vagrant/git/Test.Android/Test.Android.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2034,3): error MSB4018: at System.IO.Path.GetFullPathInternal (System.String path) [0x00000] in :0 [/Users/vagrant/git/Test.Android/Test.Android.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2034,3): error MSB4018: at System.IO.FileInfo.Init (System.String fileName, System.Boolean checkHost) [0x00007] in :0 [/Users/vagrant/git/Test.Android/Test.Android.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2034,3): error MSB4018: at System.IO.FileInfo…ctor (System.String fileName) [0x00014] in :0 [/Users/vagrant/git/Test.Android/Test.Android.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2034,3): error MSB4018: at (wrapper remoting-invoke-with-check) System.IO.FileInfo…ctor(string) [/Users/vagrant/git/Test.Android/Test.Android.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2034,3): error MSB4018: at Xamarin.Android.Tasks.ZipArchiveEx.AddFiles (System.String folder, System.String folderInArchive) [0x00021] in :0 [/Users/vagrant/git/Test.Android/Test.Android.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2034,3): error MSB4018: at Xamarin.Android.Tasks.ZipArchiveEx.AddDirectory (System.String folder, System.String folderInArchive) [0x00064] in :0 [/Users/vagrant/git/Test.Android/Test.Android.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2034,3): error MSB4018: at Xamarin.Android.Tasks.Javac.Execute () [0x00048] in :0 [/Users/vagrant/git/Test.Android/Test.Android.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2034,3): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in <99064ce461714f6a83a1f24370e1d7b8>:0 [/Users/vagrant/git/Test.Android/Test.Android.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2034,3): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder+d__26.MoveNext () [0x00212] in <99064ce461714f6a83a1f24370e1d7b8>:0 [/Users/vagrant/git/Test.Android/Test.Android.csproj]

The branch builds fine on many other machines, but seems to run into issues on Bitrise, has anyone seen this before?

Hi @bryce-ifit

Did you contact our support via the onsite chat/email? I remember seeing this issue there.

I did, and while they did have a few suggestions, nothing seemed to resolve the issue.

Fortunately this morning I had a breakthrough, as installing the current Bitrise JDK version (1.8.0_162) caused the issue to happen locally (and consequently upgrading to 1.8.0_171 fixed it).

Now I am at either waiting for the JDK to be updated in the VM templates or manually installing it (Homebrew/Cask route was tried, didn’t seem too promissing for installing the specific latest version).

1 Like

Sounds promising, good catch! :wink:

Which stack is this?

What’s the issue with brew?

All of them at the moment, Beta, Stable, and previous of the Xamarin Hybrid stacks.

The latest version in brew seemed to be pointing toward 162, but the latest available version from oracle is 171 (side note on this I am no Homebrew expert).

So update on this, I was able to get Java updated via homebrew:

brew update
brew tap caskroom/versions

brew cask info java8
brew cask uninstall java8
brew cask install java8

And Im still running into the issue :frowning:

It’s possible that a system reboot is required, I know I did that before my local issue went away.

Ok, so I have finally found the solution:

The issue WAS with the ulimit, but it needed to be run in the same shell session as the build. So, I wrote a script that ran the ulimit then an msbuild, and that solved the issue.

Java version will be update in a couple of hours, as part of this week’s VM updates:

Update to Java: java version "1.8.0_172" - Weekly vm update 2018 04 19 by kdobmayer · Pull Request #206 · bitrise-io/bitrise.io · GitHub

Will let you know as soon as it’s in production, hopefully you’ll be able to remove your tweaks after that :wink:

All the VMs are updated by now, so if you have some time @bryce-ifit please test again, Java is updated on both Visual Studio for Mac stack (Stable & Beta) and let us know how it goes or if you’d have any questions! :wink:

Will do, and thanks for the great support!

1 Like

Any time :wink: Thanks for using Bitrise! :slight_smile:

This topic was automatically closed after 13 days. New replies are no longer allowed.