Flutter:打开文件过多异常(MacOS)
Posted
技术标签:
【中文标题】Flutter:打开文件过多异常(MacOS)【英文标题】:Flutter: Too many open files exception (MacOS) 【发布时间】:2021-04-16 00:55:49 【问题描述】:今天我在我的应用程序中看到一个奇怪的错误,它是这样的
FileSystemException: FileSystemException: Getting current working directory failed, path = '' (OS Error: Too many open files in system, errno = 23)
我的应用拥有大量资产,这可能是导致此问题的原因?
这感觉像是两个不同的问题。一是我们持有包:在 Mac 上测试代码并试图一次驱动太多测试
颤抖的医生
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-GB)
• Flutter version 1.22.5 at /Users/mac/Development/flutter
• Framework revision 7891006299 (4 weeks ago), 2020-12-10 11:54:40 -0800
• Engine revision ae90085a84
• Dart version 2.10.4
[✓] android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/mac/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for ios and macOS (Xcode 12.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.0, Build version 12A7209
• CocoaPods version 1.10.0
[!] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
如何在 macOS 上更改打开文件限制?
【问题讨论】:
【参考方案1】:Mac OS 一次可以打开多少个文件的默认限制相当低。如果遇到此限制,请使用ulimit
命令增加可用文件处理程序的数量:
ulimit -S -n 2048
如果您使用 Travis 或 Cirrus 进行测试,请通过将同一行分别添加到 flutter/.travis.yml 或 flutter/.cirrus.yml 来增加它们可以打开的可用文件处理程序的数量。
【讨论】:
以上是关于Flutter:打开文件过多异常(MacOS)的主要内容,如果未能解决你的问题,请参考以下文章
解决: java.io.IOException: 打开的文件过多 的问题