{"record":{"id":"7027e02cc2d56d9b","repo":"gleam-lang/gleam","slug":"unable-to-start-tokio-async-runtime","errorCode":null,"errorMessage":"Unable to start Tokio async runtime","messagePattern":"Unable to start Tokio async runtime","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler-cli/src/dependencies.rs","lineNumber":99,"sourceCode":"        build_tools: vec![],\n        name: config.name.clone(),\n        requirements: config.all_direct_dependencies()?.keys().cloned().collect(),\n        version: config.version.clone(),\n        source: ManifestPackageSource::Local {\n            path: paths.root().to_path_buf(),\n        },\n        otp_app: None,\n    };\n\n    // Get the manifest packages and add the root package to the vec\n    let mut packages = manifest.packages.iter().cloned().collect_vec();\n    packages.push(root_package);\n\n    list_package_and_dependencies_tree(std::io::stdout(), options, packages.clone(), config.name)\n}\n\nfn get_manifest_details(paths: &ProjectPaths) -> Result<(PackageConfig, Manifest)> {\n    let runtime = tokio::runtime::Runtime::new().expect(\"Unable to start Tokio async runtime\");\n    let config = crate::config::root_config(paths)?;\n    let package_fetcher = PackageFetcher::new(runtime.handle().clone());\n    let dependency_manager = DependencyManagerConfig {\n        use_manifest: UseManifest::Yes,\n        check_major_versions: CheckMajorVersions::No,\n    }\n    .into_dependency_manager(\n        runtime.handle().clone(),\n        package_fetcher,\n        cli::Reporter::new(),\n        Mode::Dev,\n    );\n    let manifest = dependency_manager\n        .resolve_versions(paths, &config, Vec::new())?\n        .manifest;\n    Ok((config, manifest))\n}\n","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/gleam-lang/gleam/blob/7e623aa83da3776faee50ca4ab9a6c40124acd95/compiler-cli/src/dependencies.rs#L81-L117","documentation":"`get_manifest_details` in compiler-cli/src/dependencies.rs:99 builds a Tokio multi-threaded runtime so it can query the Hex API when resolving dependency metadata for `gleam deps tree`/`gleam deps list`. `tokio::runtime::Runtime::new()` fails when the OS refuses resources the runtime needs — worker threads (`clone` under thread/process limits) or the epoll/timerfd descriptors for the IO and time drivers — and `.expect(\"Unable to start Tokio async runtime\")` converts that into a process abort.","triggerScenarios":"Running `gleam deps tree` or `gleam deps list` where `Runtime::new()` fails: `ulimit -u`/RLIMIT_NPROC or a cgroup `pids.max` limit blocking worker-thread creation, `ulimit -n`/RLIMIT_NOFILE exhaustion (EMFILE) when creating the epoll/timer fds, or a seccomp/AppArmor profile blocking `clone`/`epoll_create1`.","commonSituations":"Minimal Docker images or Kubernetes pods with `--pids-limit`/`podPidsLimit` set low; build agents with thousands of leaked fds; hardened runtimes (gVisor, custom seccomp) blocking syscalls Tokio needs; memory-exhausted machines that cannot allocate thread stacks.","solutions":["Check and raise thread/process limits: `ulimit -u` on the host, `--pids-limit` for Docker, `podPidsLimit`/kubelet config in Kubernetes","Check and raise fd limits: `ulimit -n 4096`; find fd leaks with `ls /proc/$$/fd | wc -l`","Free memory or raise the container memory limit so Tokio worker thread stacks are allocatable","If sandboxed, permit `clone`, `epoll_create1`, `eventfd`, and `timerfd_*` syscalls or run outside that sandbox","Re-run `gleam deps tree` once limits are fixed — no project change is required"],"exampleFix":"# before: panics 'Unable to start Tokio async runtime'\ndocker run --pids-limit 10 my-ci gleam deps tree\n\n# after: leave room for Tokio worker threads\ndocker run --pids-limit 512 my-ci gleam deps tree","handlingStrategy":"validation","validationCode":"# fail fast if the box cannot host a Tokio runtime\nnproc_lim=$(ulimit -u); nofile=$(ulimit -n)\n[ \"$nproc_lim\" != \"unlimited\" ] && [ \"$nproc_lim\" -lt 256 ] && { echo \"nproc limit too low: $nproc_lim\"; exit 1; }\n[ \"$nofile\" != \"unlimited\" ] && [ \"$nofile\" -lt 256 ] && { echo \"nofile limit too low: $nofile\"; exit 1; }\ngleam deps tree","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bake sane rlimits into CI images: `ulimit -n 4096` and adequate `ulimit -u`","Set container `--pids-limit`/`podPidsLimit` to at least a few hundred","Avoid running gleam on agents whose fd/process tables are nearly exhausted"],"tags":["gleam","tokio","async-runtime","deps","cli","resource-limits"],"backgroundTag":"tokio-runtime-start-failed","analyzedSha":"7e623aa83da3776faee50ca4ab9a6c40124acd95","analyzedAt":"2026-08-17T00:07:02.091Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}