This repository has been archived by the owner. It is now read-only.

Doesn't run "out of the box" on Mac OS X (System.IO.IOException: Too many open files) #2118

Closed
Daniel15 opened this Issue Mar 4, 2015 · 8 comments

Comments

Projects
None yet
5 participants
@Daniel15
Copy link
Contributor

Daniel15 commented Mar 4, 2015

Mono 3.12.0
Mac OS X Yosemite (10.10.2)

I made a site using the Yeoman generator (as per http://blogs.msdn.com/b/webdev/archive/2014/08/12/develop-asp-net-vnext-applications-on-a-mac.aspx), selected "Web Application" in the generator (which includes all the default sample pages), and tried running it unmodified:

yo aspnet
cd MyApp
kpm restore
kpm build
k kestrel

This resulted in a "Too many open files" exception:

danlo-mbp1:YoWebapp danlo$ k kestrel
System.IO.IOException: Too many open files
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions)
  at Microsoft.AspNet.FileProviders.PhysicalFileProvider+PhysicalFileInfo.CreateReadStream () [0x00000] in <filename unknown>:0
  at Microsoft.AspNet.Mvc.Razor.RazorPreCompiler.GetCacheEntry (Microsoft.AspNet.Mvc.Razor.RelativeFileInfo fileInfo) [0x00000] in <filename unknown>:0
  at Microsoft.AspNet.Mvc.Razor.RazorPreCompiler.OnCacheMiss (ICacheSetContext cacheSetContext) [0x00000] in <filename unknown>:0
  at Microsoft.Framework.Cache.Memory.CacheExtensions+<>c__DisplayClass7_0`1[Microsoft.AspNet.Mvc.Razor.PrecompilationCacheEntry].<Set>b__0 (ICacheSetContext context) [0x00000] in <filename unknown>:0
  at Microsoft.Framework.Cache.Memory.MemoryCache.Set (System.String key, IEntryLink link, System.Object state, System.Func`2 create) [0x00000] in <filename unknown>:0
  at Microsoft.Framework.Cache.Memory.CacheExtensions.Set (IMemoryCache cache, System.String key, System.Object state, System.Func`2 create) [0x00000] in <filename unknown>:0
  at Microsoft.Framework.Cache.Memory.CacheExtensions.Set[PrecompilationCacheEntry] (IMemoryCache cache, System.String key, System.Object state, System.Func`2 create) [0x00000] in <filename unknown>:0
  at Microsoft.Framework.Cache.Memory.CacheExtensions.GetOrSet[PrecompilationCacheEntry] (IMemoryCache cache, System.String key, System.Object state, System.Func`2 create) [0x00000] in <filename unknown>:0
  at Microsoft.AspNet.Mvc.Razor.RazorPreCompiler+<>c__DisplayClass17_0.<CreateCompilationDescriptors>b__0 (Int32 index) [0x00000] in <filename unknown>:0
  at System.Threading.Tasks.Parallel+<For>c__AnonStorey0.<>m__0 (Int32 index, System.Threading.Tasks.ParallelLoopState state) [0x00000] in <filename unknown>:0
  at System.Threading.Tasks.Parallel+<For>c__AnonStorey1.<>m__0 (Int32 i, System.Threading.Tasks.ParallelLoopState s, System.Object l) [0x00000] in <filename unknown>:0
  at System.Threading.Tasks.Parallel+<For>c__AnonStorey2`1[TLocal].<>m__0 () [0x00000] in <filename unknown>:0
  at System.Threading.Tasks.TaskActionInvoker+ActionInvoke.Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in <filename unknown>:0
  at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <filename unknown>:0
  at System.Threading.Tasks.Task.<ThreadStart>m__1 (System.Object l) [0x00000] in <filename unknown>:0
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x00000] in <filename unknown>:0
  at System.Threading.Tasks.Task.ThreadStart () [0x00000] in <filename unknown>:0

I tried increasing the limit but I'm still getting the same exception. Are there other settings I need to set? Is this documented somewhere yet?

Thanks!

@samritchie

This comment has been minimized.

Copy link

samritchie commented Mar 4, 2015

+1

The HelloMvc sample from aspnet/Home runs, as does the yeoman EmptyApplication, but the WebApplication template doesn't. I might start randomly deleting stuff and see what works.

@samritchie

This comment has been minimized.

Copy link

samritchie commented Mar 4, 2015

yo generator is definitely generating beta3 dependencies. Yes, I managed to fix the incorrect HelloMVC versions.

Do you know if this specific issue is fixed in the dev builds? I've only just finished switching everything back to master.

@adaam2

This comment has been minimized.

Copy link

adaam2 commented Mar 4, 2015

@antonmes That seemed to work for me. Thanks!

@danroth27 danroth27 closed this Mar 4, 2015

@danroth27 danroth27 added the external label Mar 4, 2015

@Daniel15

This comment has been minimized.

Copy link
Contributor

Daniel15 commented Mar 4, 2015

Awesome, thanks @antonmes! Do you know if there's a Mono bug number we can post here for reference?

@Daniel15

This comment has been minimized.

Copy link
Contributor

Daniel15 commented Mar 4, 2015

Also note that MONO_MANAGED_WATCHER=disabled will totally disable file system watching, and I'm not sure if that will break anything or not. Perhaps I'll just try downgrading Mono, or using a Linux VM instead.

@Daniel15

This comment has been minimized.

Copy link
Contributor

Daniel15 commented Mar 4, 2015

Ah I see, that explains a bug I encountered around a year ago: https://bugzilla.xamarin.com/show_bug.cgi?id=19071

@rynowak

This comment has been minimized.

Copy link
Member

rynowak commented Mar 5, 2015

FYI if you find that you need to disable the filewatcher you may run into issues with timing when updating a .cshtml while the site is running. This is primarily what we're using it for.

@pranavkm in case he has thoughts

@Daniel15

This comment has been minimized.

Copy link
Contributor

Daniel15 commented Mar 5, 2015

The Mono release notes say that it's only an issue when watching "very large directories". Maybe only watching the *.cshtml files rather than the whole directory could work around the issue? I haven't looked at the code so I'm not sure what it's doing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.