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

Dotnet restore fails on OSX with too many open files error - need a generic solution for different projects #4776

Closed
livarcocc opened this issue Jan 12, 2016 · 19 comments
Assignees
Labels
Milestone

Comments

@livarcocc
Copy link
Contributor

Just run build.sh on the Mac.

I got a bunch of these at first:

Warning: FindPackagesById: System.Reflection.Emit.Lightweight
Too many open files

And then it turned into an error.

@livarcocc
Copy link
Contributor Author

@brthor Suggested a workaround, just run ulimit -n 512. We still need to prevent this from ever happening though.

@livarcocc livarcocc self-assigned this Jan 12, 2016
@livarcocc
Copy link
Contributor Author

Fixed with dotnet/cli#818

@vors
Copy link

vors commented Jan 26, 2016

Just hit it, thanks for the instruction to fix it 👍

@natemcmaster
Copy link
Contributor

We still need to prevent this from ever happening though.

As a good sample case, try restore on EntityFramework. It always fails with this error.

@livarcocc
Copy link
Contributor Author

I will re-open the issue. Seems like we need to find a generic solution to make dotnet restore as a command work, not only for the CLI restore step.

@livarcocc livarcocc reopened this Jan 27, 2016
@livarcocc livarcocc changed the title Dotnet restore fails on OSX with too many open files error Dotnet restore fails on OSX with too many open files error - need a generic solution for different projects Jan 27, 2016
@moozzyk
Copy link
Contributor

moozzyk commented Jan 27, 2016

Related: NuGet/Home#2004

@natemcmaster
Copy link
Contributor

FWIW ulimit -n 512 is not enough for big projects like EntityFramework. I have to do ulimit -n 2048 to avoid this error.

@wyoung
Copy link

wyoung commented Mar 9, 2016

Although this is Mac-specific insofar as OS X sets an unusually low limit on the number of open FDs, this is arguably a cross-platform design error in dotnet restore.

It seems that the problem is that it opens all of the NuGet HTTP connections needed to restore packages in parallel, blowing the default ulimit -n = 256 limit on OS X. But that just begs the question: why open that many parallel connections in the first place?

There are several good reasons to limit the number of simultaneous HTTP connections per server, quite aside from this client-side limit. (The C10K problem, TCP congestion issues, etc.) This is why all current web browsers limit themselves to at most 8 connections per server.

If dotnet restore behaved the same way, the Mac simultaneous open files limit would not be a problem.

The recommended workaround (ulimit -n 512) will only work as long as .NET remains the size it is now, and for relatively small projects. You can easily imagine this limit being blown again as .NET continues to grow, or on new development machines building preexisting large projects with many external dependencies.

There are several ways to fix this by making use of the rich parallel processing facilities in .NET. The recently-added Async stuff in C# provides one easy way, for example.

@agocke
Copy link
Member

agocke commented Mar 27, 2016

I just hit this again:

info :   NotFound https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-corefxtestdata/nuget/v3/flatcontainer/system.xml.xdocument/index.json 225ms
info :   GET https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-buildtools/nuget/v3/flatcontainer/microsoft.netcore.targets.dnxcore/index.json
log  : Installing System.Security.Cryptography.OpenSsl 4.0.0-beta-23504.
log  : Installing System.Security.Cryptography.Primitives 4.0.0-beta-23504.
log  : Installing System.IO.FileSystem.Watcher 4.0.0-beta-23504.
log  : Installing runtime.osx.10.10.System.Security.Cryptography.Algorithms 4.0.0-beta-23504.
log  : Installing runtime.unix.System.Security.Cryptography.Encoding 4.0.0-beta-23504.
log  : Installing runtime.osx.10.10.System.IO.FileSystem.Watcher 4.0.0-beta-23504.
info :   NotFound https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-coreclr/nuget/v3/flatcontainer/microsoft.netcore.platforms/index.json 224ms
info :   GET https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-coreclr/nuget/v3/flatcontainer/system.threading.overlapped/index.json
info :   NotFound https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-buildtools/nuget/v3/flatcontainer/system.xml.xdocument/index.json 235ms
info :   GET https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-corefxtestdata/nuget/v3/flatcontainer/system.threading.overlapped/index.json
info :   NotFound https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-coreclr/nuget/v3/flatcontainer/system.xml.readerwriter/index.json 309ms
info :   GET https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-buildtools/nuget/v3/flatcontainer/system.threading.overlapped/index.json
error: Too many open files

This is running with dotnet restore --disable-parallel.

Upping the ulimit is not an acceptable workaround -- we need to get this properly fixed ASAP.

@krwq krwq closed this as completed Apr 7, 2016
@alexandru
Copy link

I just want to report that the error still happens on OS X, after a first dotnet restore after installing the .NET Core pkg:

$ dotnet --version
...
Product Information:
 Version:     1.0.0-beta-001598
 Commit Sha:  7582649f88

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.11
 OS Platform: Darwin
 Runtime Id:  osx.10.11-x64

@ffquintella
Copy link

Well maybe wrapping the command with the ulimit before it runs ?

Or just using this on your .bashrc
alias dotnet="ulimit -n 2048; dotnet"

@NickCraver
Copy link
Member

Confirmed I'm hitting this with Dapper build scripts now. This should be reopened.

NickCraver referenced this issue in DapperLib/Dapper Apr 17, 2016
Note: these are hosed on OS X due to file handle limits, see
https://github.com/dotnet/cli/issues/809 for details.
@davidfowl
Copy link
Member

davidfowl commented Apr 17, 2016

/cc @emgarten @yishaigalatzer

@yishaigalatzer
Copy link

We just checked in a file handle leak fix, it could be related. Nick - what build are you using?

@NickCraver
Copy link
Member

@yishaigalatzer 1.0.0-rc2-002416

@agocke agocke reopened this Apr 18, 2016
@TheRealPiotrP
Copy link
Contributor

Since this is being tracked @nuget/home:2163, closing the CLI issue.

@NickCraver
Copy link
Member

Link for others: NuGet/Home#2163

@yishaigalatzer
Copy link

Comments to others - At the moment this looks like a coreFX issue, we are discussing internally and will figure out if this will get fixed for RC2 and how.

wli3 referenced this issue in wli3/cli Jul 14, 2017
Use case insensitive comparison for determining which packages should be excluded from publishing
@TyOverby
Copy link

Hit this today.

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@msftgits msftgits added this to the 1.0.0-rc2 milestone Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests