{"record":{"id":"65a1930a8a31a82a","repo":"gleam-lang/gleam","slug":"unable-to-start-tokio-async-runtime-65a193","errorCode":null,"errorMessage":"Unable to start Tokio async runtime","messagePattern":"Unable to start Tokio async runtime","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/publish.rs","lineNumber":87,"sourceCode":"        println!(\"\\nGenerated files:\");\n        for file in generated_files_added.iter().sorted() {\n            println!(\"  - {}\", file.0);\n        }\n    }\n    println!(\"\\nSource files:\");\n    for file in src_files_added.iter().sorted() {\n        println!(\"  - {file}\");\n    }\n    println!(\"\\nName: {}\", config.name);\n    println!(\"Version: {}\", config.version);\n\n    let should_publish = i_am_sure || cli::confirm(\"\\nDo you wish to publish this package?\")?;\n    if !should_publish {\n        println!(\"Not publishing.\");\n        return Ok(());\n    }\n\n    let runtime = tokio::runtime::Runtime::new().expect(\"Unable to start Tokio async runtime\");\n    let http = HttpClient::new();\n    let hex_config = hexpm::Config::new();\n    let credentials = crate::hex::HexAuthentication::new(&runtime, &http, hex_config.clone())\n        .get_or_create_api_credentials()?;\n    let credentials = crate::hex::write_credentials(&credentials)?;\n    cli::print_publishing(&config.name, &config.version);\n\n    runtime.block_on(hex::publish_package(\n        package_tarball,\n        config.version.to_string(),\n        &config.name,\n        &credentials,\n        &hex_config,\n        replace,\n        &http,\n    ))?;\n\n    cli::print_publishing_documentation();","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/gleam-lang/gleam/blob/7e623aa83da3776faee50ca4ab9a6c40124acd95/compiler-cli/src/publish.rs#L69-L105","documentation":"publish.rs::main creates its Tokio runtime with expect(\"Unable to start Tokio async runtime\") after listing files and asking 'Do you wish to publish this package?'. This is the same resource-exhaustion failure as other commands: the multi-thread runtime cannot spawn workers or register its I/O driver. The panic fires after confirmation but before hex::publish_package, so no package state changes on hex.pm.","triggerScenarios":"`gleam publish` in a CI container with low pids-limit, low ulimit -u/-v, heavy memory pressure, or a seccomp/gVisor sandbox blocking the syscalls Tokio needs — hitting exactly between the confirmation prompt and the upload.","commonSituations":"Release pipelines in Docker (default or small --pids-limit), self-hosted runners shared with many jobs, or gVisor/Firecracker CI sandboxes; the tag was pushed and CI failed at publish time.","solutions":["Re-run publish with more headroom: raise the container pids limit and thread ulimits, or exec the publish step outside the sandbox.","Relieve memory/thread pressure on the machine (wait for parallel jobs), then `gleam publish --yes` to skip the interactive prompt.","For library users of this code, replace Runtime::new() with Builder::new_current_thread().enable_all().build().","Confirm the limit in CI logs (`pids.max`, exit context) and bake a higher limit into the release job image."],"exampleFix":"# before: release job constrained by default pids limit\n- run: gleam publish --yes   # panics: Unable to start Tokio async runtime\n\n# after: publish step with adequate limits\n- run: gleam publish --yes\n  # plus container config: pids_limit: 512 (compose) or --pids-limit=512 (docker)","handlingStrategy":"retry","validationCode":"# Release pipeline preflight: enough pids and memory for a Tokio runtime\n[ \"$(cat /sys/fs/cgroup/pids/pids.max 2>/dev/null)\" != \"16\" ] || (echo raise pids limit; exit 1)\navail_kb=$(awk '/MemAvailable/{print $2}' /proc/meminfo); [ \"$avail_kb\" -gt 262144 ] || exit 1\ngleam publish --yes","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure release CI containers with pids_limit >= 512 and a couple of GiB memory.","Don't overlap `gleam publish` with parallel compilation jobs on thread-starved runners.","Because the panic happens before hex::publish_package, re-running publish after fixing limits is safe (no partial upload)."],"tags":["panic","tokio","runtime","threads","resource-limits","publish","hex-pm","ci"],"backgroundTag":"thread-creation-failed","analyzedSha":"7e623aa83da3776faee50ca4ab9a6c40124acd95","analyzedAt":"2026-08-17T00:07:02.091Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}