From 15f139b2dcbd106f83866001550014e7019d23a9 Mon Sep 17 00:00:00 2001 From: Szymon Osiecki Date: Mon, 2 Mar 2026 07:11:06 +0100 Subject: [PATCH] feat(sh): fix the "Too many open files" error --- .assets/provision/fix_no_file.sh | 15 +++++++++++++++ wsl/wsl_setup.ps1 | 1 + 2 files changed, 16 insertions(+) create mode 100755 .assets/provision/fix_no_file.sh diff --git a/.assets/provision/fix_no_file.sh b/.assets/provision/fix_no_file.sh new file mode 100755 index 00000000..2c6fcfba --- /dev/null +++ b/.assets/provision/fix_no_file.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env sh +: ' +# Fixes the "Too many open files" error. +sudo .assets/provision/fix_no_file.sh +' +set -eu + +if [ "$(id -u)" -ne 0 ]; then + printf '\e[31;1mRun the script as root.\e[0m\n' >&2 + exit 1 +fi + +if [ -f '/etc/systemd/user.conf' ] && grep -qw '#DefaultLimitNOFILE' '/etc/systemd/user.conf'; then + sed -i 's/^#DefaultLimitNOFILE=.*/DefaultLimitNOFILE=65535/' /etc/systemd/user.conf +fi diff --git a/wsl/wsl_setup.ps1 b/wsl/wsl_setup.ps1 index 5d15ad5c..2270eadc 100644 --- a/wsl/wsl_setup.ps1 +++ b/wsl/wsl_setup.ps1 @@ -388,6 +388,7 @@ process { # *install packages Show-LogContext 'updating system' + wsl.exe --distribution $Distro --user root --exec .assets/provision/fix_no_file.sh wsl.exe --distribution $Distro --user root --exec .assets/provision/fix_secure_path.sh wsl.exe --distribution $Distro --user root --exec .assets/provision/upgrade_system.sh wsl.exe --distribution $Distro --user root --exec .assets/provision/install_base.sh $chk.user