From a7d54f2f1e21c0b9bea9c0b4521675d917d981f1 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Sun, 15 Nov 2026 02:51:04 +0800 Subject: [PATCH 1/4] Name the dependency being resolved; say which modes are available --- src/commands/add.rs | 6 +++++- src/commands/generation.rs | 6 +++++- src/commands/pin.rs | 7 ++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/commands/add.rs b/src/commands/add.rs index 405d1f7..d4d7e14 100644 --- a/src/commands/add.rs +++ b/src/commands/add.rs @@ -121,7 +121,8 @@ pub fn run( // Before fetching anything: the entry has to be writable. entry_fields(&dependency)?; - ui::step(format!("Resolving {name}{}", ui::at_path(work_dir))); + ui::step(format!("Resolving dependency '{name}'")); + let spinner = ui::spinner(match source { Source::Path(_) => "compiling", Source::Git { .. } => "fetching and compiling", @@ -132,8 +133,11 @@ pub fn run( let resolve = |dependency: &DependencyConfig| { accept::quietly(|| deps::resolve(dependency, work_dir, &cache_dir)) }; + let mut resolved = resolve(&dependency); + ui::finish_spinner(spinner); + // A dependency with `@unverified` protocols resolves only once they're // accepted: show what they give up and ask, then try again. if resolved.is_err() { diff --git a/src/commands/generation.rs b/src/commands/generation.rs index 814e461..59ecf4a 100644 --- a/src/commands/generation.rs +++ b/src/commands/generation.rs @@ -187,7 +187,7 @@ fn generate_once(work_dir: &Path, overrides: &Overrides, dry_run: bool, list: bo "lib" => Mode::Lib, other => { return Err(miette!( - "target `{}`: mode `{other}` is not supported yet (`code`, `lib`)", + "target `{}`: mode `{other}` is not supported (available: `code`, `lib`)", t.language )) } @@ -232,7 +232,9 @@ fn generate_once(work_dir: &Path, overrides: &Overrides, dry_run: bool, list: bo )); } } + let ext = info.ext.clone(); + // The page the generator itself names for its connections. let connections_doc = info.doc(Topic::Connections).map(str::to_owned); (Source::External(generator), ext, connections_doc) @@ -296,11 +298,13 @@ fn generate_once(work_dir: &Path, overrides: &Overrides, dry_run: bool, list: bo "language: {}, version: {}, mode: {}", t.language, t.lang_version, t.mode, ); + ui::detail(if ui::plain() { label } else { format!("⚙️ {label}") }); + // A given-up guarantee, shown where it's given up. if let Some(reason) = &t.validate_on_decode_off { ui::note(format!( diff --git a/src/commands/pin.rs b/src/commands/pin.rs index 68c655d..986a42a 100644 --- a/src/commands/pin.rs +++ b/src/commands/pin.rs @@ -56,6 +56,7 @@ pub fn run(work_dir: &Path, name: &str, to: Option, accept_unverified: boo } _ => {} } + for value in [commit_of(&dependency), version_of(&dependency)] .into_iter() .flatten() @@ -68,17 +69,20 @@ pub fn run(work_dir: &Path, name: &str, to: Option, accept_unverified: boo } set_hash(&mut dependency, None); - ui::step(format!("Resolving {name}{}", ui::at_path(work_dir))); + ui::step(format!("Resolving dependency '{name}'")); + let spinner = ui::spinner(match dependency.source { DependencySource::Git { .. } => "fetching and compiling", _ => "compiling", }); + let cache_dir = work_dir.join(DEPS_CACHE_DIR); // Resolving without a hash warns that it's trusted, and suggests the very // pin this command writes: keep that out of a normal run. let resolve = |dependency: &DependencyConfig| { accept::quietly(|| deps::resolve(dependency, work_dir, &cache_dir)) }; + let mut resolved = resolve(&dependency); ui::finish_spinner(spinner); @@ -105,6 +109,7 @@ pub fn run(work_dir: &Path, name: &str, to: Option, accept_unverified: boo resolved = resolve(&dependency); } } + let resolved = resolved.map_err(|e| core_err("couldn't resolve the dependency", e))?; let new_hash = format!("blake3:{}", resolved.content_hash.to_hex()); set_hash(&mut dependency, Some(new_hash.clone())); From d6dff1ebf659be93069257ad7039aabe87af6383 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Sun, 15 Nov 2026 02:55:30 +0800 Subject: [PATCH 2/4] Fill GenerateRequest::dependencies and use facts::needed_in; pin generation at da81b68 (generation#143) --- Cargo.lock | 28 ++++++++--- Cargo.toml | 6 +-- src/commands/generation.rs | 37 +++++++++++++- tests/cli/generation.rs | 98 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 157 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2462e33..7f461de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -476,7 +476,7 @@ dependencies = [ "clap", "clap_complete", "clap_mangen", - "comline-codegen", + "comline-codegen 0.1.0 (git+https://github.com/ComlineProject/generation?rev=da81b688c949a0ebad4f213d6fdb648920cf641d)", "comline-codegen-rust", "comline-codegen-typescript", "comline-core", @@ -526,12 +526,26 @@ dependencies = [ "toml", ] +[[package]] +name = "comline-codegen" +version = "0.1.0" +source = "git+https://github.com/ComlineProject/generation?rev=da81b688c949a0ebad4f213d6fdb648920cf641d#da81b688c949a0ebad4f213d6fdb648920cf641d" +dependencies = [ + "comline-core", + "eyre", + "miette", + "schemars", + "serde", + "serde_json", + "toml", +] + [[package]] name = "comline-codegen-rust" version = "0.1.0" source = "git+https://github.com/ComlineProject/comline-rust?rev=df91e2e0a416cab594303f11d44a6555a72f891b#df91e2e0a416cab594303f11d44a6555a72f891b" dependencies = [ - "comline-codegen", + "comline-codegen 0.1.0 (git+https://github.com/ComlineProject/generation?rev=05771e0679ff514da3ba73a3b0b94643e5262fe5)", "comline-core", "eyre", ] @@ -541,7 +555,7 @@ name = "comline-codegen-typescript" version = "0.1.0" source = "git+https://github.com/ComlineProject/comline-typescript?rev=8d829be859feac26d775f4877f098fedc38fdd9f#8d829be859feac26d775f4877f098fedc38fdd9f" dependencies = [ - "comline-codegen", + "comline-codegen 0.1.0 (git+https://github.com/ComlineProject/generation?rev=05771e0679ff514da3ba73a3b0b94643e5262fe5)", "comline-core", "eyre", ] @@ -584,9 +598,9 @@ source = "git+https://github.com/ComlineProject/core?rev=868e8310e33df317e3cba4f [[package]] name = "comline-doc-html" version = "0.1.0" -source = "git+https://github.com/ComlineProject/generation?rev=05771e0679ff514da3ba73a3b0b94643e5262fe5#05771e0679ff514da3ba73a3b0b94643e5262fe5" +source = "git+https://github.com/ComlineProject/generation?rev=da81b688c949a0ebad4f213d6fdb648920cf641d#da81b688c949a0ebad4f213d6fdb648920cf641d" dependencies = [ - "comline-codegen", + "comline-codegen 0.1.0 (git+https://github.com/ComlineProject/generation?rev=da81b688c949a0ebad4f213d6fdb648920cf641d)", "eyre", "pulldown-cmark", "serde_json", @@ -595,9 +609,9 @@ dependencies = [ [[package]] name = "comline-doc-markdown" version = "0.1.0" -source = "git+https://github.com/ComlineProject/generation?rev=05771e0679ff514da3ba73a3b0b94643e5262fe5#05771e0679ff514da3ba73a3b0b94643e5262fe5" +source = "git+https://github.com/ComlineProject/generation?rev=da81b688c949a0ebad4f213d6fdb648920cf641d#da81b688c949a0ebad4f213d6fdb648920cf641d" dependencies = [ - "comline-codegen", + "comline-codegen 0.1.0 (git+https://github.com/ComlineProject/generation?rev=da81b688c949a0ebad4f213d6fdb648920cf641d)", "eyre", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 8f29862..22f2e4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,12 +53,12 @@ comline-core = { git = "https://github.com/ComlineProject/core", rev = "868e8310 # `comline-codegen`'s types, so the rev below must be byte-identical to the # one *they* pin - Cargo only unifies a git dependency across identical rev # strings, and two copies of `GenRequest` are two incompatible types. -comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "05771e0679ff514da3ba73a3b0b94643e5262fe5" } +comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "da81b688c949a0ebad4f213d6fdb648920cf641d" } # The official Markdown and HTML documentation renderers (`comline doc`), # linked in like the official generators. Same generation rev as # `comline-codegen`. -comline-doc-markdown = { git = "https://github.com/ComlineProject/generation", rev = "05771e0679ff514da3ba73a3b0b94643e5262fe5" } -comline-doc-html = { git = "https://github.com/ComlineProject/generation", rev = "05771e0679ff514da3ba73a3b0b94643e5262fe5" } +comline-doc-markdown = { git = "https://github.com/ComlineProject/generation", rev = "da81b688c949a0ebad4f213d6fdb648920cf641d" } +comline-doc-html = { git = "https://github.com/ComlineProject/generation", rev = "da81b688c949a0ebad4f213d6fdb648920cf641d" } comline-codegen-rust = { git = "https://github.com/ComlineProject/comline-rust", rev = "df91e2e0a416cab594303f11d44a6555a72f891b", optional = true } comline-codegen-typescript = { git = "https://github.com/ComlineProject/comline-typescript", rev = "8d829be859feac26d775f4877f098fedc38fdd9f", optional = true } # `comline conformance`: the conformance runner (corpus loading, judging, diff --git a/src/commands/generation.rs b/src/commands/generation.rs index 59ecf4a..a1ecc0e 100644 --- a/src/commands/generation.rs +++ b/src/commands/generation.rs @@ -74,6 +74,11 @@ struct GenVersion { package_version: String, schemas: Vec<(String, Vec)>, // (namespace path, frozen units) + /// The names the version gives its dependencies. A dependency's schemas + /// are among `schemas`, under its name as the namespace's first segment; + /// this is how a generator tells them from the package's own. + dependencies: Vec, + /// The version's own `wire.format`: a built version keeps the format it /// was built with. wire_format: String, @@ -162,6 +167,14 @@ fn generate_once(work_dir: &Path, overrides: &Overrides, dry_run: bool, list: bo }) .collect(); + // The names the package gives its dependencies, the way core splits a + // package's schemas from its dependencies'. + let live_dependencies: Vec = context + .dependency_configs + .iter() + .map(|(name, _)| name.clone()) + .collect(); + // External generators, described once each. A target that names one // and no `language` takes the one language it offers. let mut externals = Externals::default(); @@ -277,7 +290,13 @@ fn generate_once(work_dir: &Path, overrides: &Overrides, dry_run: bool, list: bo } }; - let versions = expand_versions(&t.versions, work_dir, &live_schemas, config_units)?; + let versions = expand_versions( + &t.versions, + work_dir, + &live_schemas, + &live_dependencies, + config_units, + )?; if mode == Mode::Lib && versions.len() > 1 { return Err(miette!( "target `{}`: `lib` mode does not support multiple package versions yet", @@ -339,6 +358,7 @@ fn generate_once(work_dir: &Path, overrides: &Overrides, dry_run: bool, list: bo // Filled just below. encodings: Default::default(), facts: None, + dependencies: gv.dependencies.clone(), }; // The type each encoding the package uses maps to in this // language: comline.toml's mapping, else the declaring package's @@ -522,6 +542,7 @@ fn expand_versions( spec: &VersionSpec, work_dir: &Path, live: &[(String, Vec)], + live_dependencies: &[String], live_config: &[ConfigUnit], ) -> Result> { match spec { @@ -537,6 +558,7 @@ fn expand_versions( Ok(vec![GenVersion { package_version, schemas: live.to_vec(), + dependencies: live_dependencies.to_vec(), wire_format, facts: FactsSource::WorkingTree, }]) @@ -591,9 +613,20 @@ fn gen_version_from_commit( .collect(); let config = history::load_config(store, commit)?; + // The dependencies the build vendored, by the names it stored them under. + let configs = history::load_stored_configs(store, commit)?; + let mut dependencies: Vec = configs + .dependencies + .into_iter() + .map(|(name, _)| name) + .chain(configs.unstored) + .collect(); + dependencies.sort(); + dependencies.dedup(); Ok(GenVersion { package_version: version.to_owned(), schemas, + dependencies, wire_format: frozen::wire_format(&config).to_string(), facts: FactsSource::Commit(*hash), }) @@ -615,7 +648,7 @@ fn facts_for( request: &GenerateRequest, source: &FactsSource, ) -> Result> { - if !comline_codegen::facts::needed(&request.schemas, &request.encodings) { + if !comline_codegen::facts::needed_in(request) { return Ok(None); } let facts = match source { diff --git a/tests/cli/generation.rs b/tests/cli/generation.rs index 1620a18..a4a4046 100644 --- a/tests/cli/generation.rs +++ b/tests/cli/generation.rs @@ -1438,3 +1438,101 @@ fn datagram3_and_comline2_take_their_facts_from_the_last_build() { assert!(code.contains(call), "missing `{call}` in:\n{code}"); } } + +// -------- a dependency's protocols the package doesn't reach (generation#143) -------- + +/// A package `app` that uses only the types of its dependency `greeting`, +/// which declares a protocol under `datagram@3` and `comline@2`. Returns +/// `app`'s directory, declaring Rust and TypeScript. +fn app_using_a_dependencys_types(root: &std::path::Path) -> std::path::PathBuf { + let greeting = root.join("greeting"); + comline_cmd() + .current_dir(root) + .args(["new", "greeting"]) + .assert() + .success(); + let config = fs::read_to_string(greeting.join("config.idp")) + .unwrap() + .replace( + "// wire = { format = \"packed@1\" framing = \"datagram@3\" }", + "wire = { format = \"packed@1\" framing = \"datagram@3\" }\n\ + handshake = { name = \"comline@2\" newer_consumer = \"refuse\" }", + ); + fs::write(greeting.join("config.idp"), config).unwrap(); + fs::write( + greeting.join("src/greeting.ids"), + "struct Hello {\n name: char[max 32]\n}\n\n\ + protocol Greeter {\n function greet(name: char[max 32]) -> u32;\n}\n", + ) + .unwrap(); + + let app = fixture_project(root); + let config = fs::read_to_string(app.join("config.idp")) + .unwrap() + .replace( + "rust#1.85.0 = {}", + "rust#1.85.0 = {}\n typescript#5.0 = {}", + ); + fs::write(app.join("config.idp"), config).unwrap(); + add_to_config( + &app, + "dependencies = {\n greeting = { path = \"../greeting\" }\n}", + ); + fs::write( + app.join("src/holder.ids"), + "use greeting::greeting::Hello\n\nstruct Holder {\n hello: Hello\n}\n", + ) + .unwrap(); + app +} + +fn generate_for(app: &std::path::Path, target: &str) { + comline_cmd() + .current_dir(app) + .args(["generation", "--target", target]) + .assert() + .success(); +} + +/// The dependency's protocol isn't on the package's connection, and nothing +/// of it is addressed: the package has none of its own, so there's no +/// facts to take from a build either. +#[test] +fn a_dependencys_protocol_the_package_does_not_reach_is_left_alone() { + let temp = tempfile::tempdir().unwrap(); + let app = app_using_a_dependencys_types(temp.path()); + + for target in ["rust", "typescript"] { + generate_for(&app, target); + } + assert!(app.join("generated/rust/holder.rs").exists()); +} + +/// The same from a built version: the package's dependencies come from the +/// configs the build stored. +#[test] +fn a_built_versions_dependency_protocol_is_left_alone_too() { + let temp = tempfile::tempdir().unwrap(); + let app = app_using_a_dependencys_types(temp.path()); + comline_cmd() + .current_dir(&app) + .arg("build") + .assert() + .success(); + comline_cmd() + .current_dir(&app) + .arg("release") + .assert() + .success(); + fs::write( + app.join("comline.toml"), + "[generate]\npackage_versions = \"all\"\n\ + layout = \"{{language}}/{{package_version}}/{{namespace}}.{{ext}}\"\n", + ) + .unwrap(); + + for target in ["rust", "typescript"] { + generate_for(&app, target); + } + assert!(app.join("generated/rust/0.1.0/holder.rs").exists()); +} From 16e0378e08c84a3541870e6843dc6073dfe4b882 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Sun, 15 Nov 2026 03:12:12 +0800 Subject: [PATCH 3/4] Pin comline-rust at 6db2757 and comline-typescript at bcec31d (generation#143) --- Cargo.lock | 28 +++++++--------------------- Cargo.toml | 4 ++-- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f461de..6c93f99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -476,7 +476,7 @@ dependencies = [ "clap", "clap_complete", "clap_mangen", - "comline-codegen 0.1.0 (git+https://github.com/ComlineProject/generation?rev=da81b688c949a0ebad4f213d6fdb648920cf641d)", + "comline-codegen", "comline-codegen-rust", "comline-codegen-typescript", "comline-core", @@ -512,20 +512,6 @@ name = "comline-catalog" version = "0.11.0" source = "git+https://github.com/ComlineProject/runtime?rev=8f8c0cb6fb0bc3a734aafbdbbf187fb9da73e00d#8f8c0cb6fb0bc3a734aafbdbbf187fb9da73e00d" -[[package]] -name = "comline-codegen" -version = "0.1.0" -source = "git+https://github.com/ComlineProject/generation?rev=05771e0679ff514da3ba73a3b0b94643e5262fe5#05771e0679ff514da3ba73a3b0b94643e5262fe5" -dependencies = [ - "comline-core", - "eyre", - "miette", - "schemars", - "serde", - "serde_json", - "toml", -] - [[package]] name = "comline-codegen" version = "0.1.0" @@ -543,9 +529,9 @@ dependencies = [ [[package]] name = "comline-codegen-rust" version = "0.1.0" -source = "git+https://github.com/ComlineProject/comline-rust?rev=df91e2e0a416cab594303f11d44a6555a72f891b#df91e2e0a416cab594303f11d44a6555a72f891b" +source = "git+https://github.com/ComlineProject/comline-rust?rev=6db2757b6d1e7df44df8c47adc8cad5bec1559c1#6db2757b6d1e7df44df8c47adc8cad5bec1559c1" dependencies = [ - "comline-codegen 0.1.0 (git+https://github.com/ComlineProject/generation?rev=05771e0679ff514da3ba73a3b0b94643e5262fe5)", + "comline-codegen", "comline-core", "eyre", ] @@ -553,9 +539,9 @@ dependencies = [ [[package]] name = "comline-codegen-typescript" version = "0.1.0" -source = "git+https://github.com/ComlineProject/comline-typescript?rev=8d829be859feac26d775f4877f098fedc38fdd9f#8d829be859feac26d775f4877f098fedc38fdd9f" +source = "git+https://github.com/ComlineProject/comline-typescript?rev=bcec31dd13320613bcc1dcb10dcbc72f9a1011f9#bcec31dd13320613bcc1dcb10dcbc72f9a1011f9" dependencies = [ - "comline-codegen 0.1.0 (git+https://github.com/ComlineProject/generation?rev=05771e0679ff514da3ba73a3b0b94643e5262fe5)", + "comline-codegen", "comline-core", "eyre", ] @@ -600,7 +586,7 @@ name = "comline-doc-html" version = "0.1.0" source = "git+https://github.com/ComlineProject/generation?rev=da81b688c949a0ebad4f213d6fdb648920cf641d#da81b688c949a0ebad4f213d6fdb648920cf641d" dependencies = [ - "comline-codegen 0.1.0 (git+https://github.com/ComlineProject/generation?rev=da81b688c949a0ebad4f213d6fdb648920cf641d)", + "comline-codegen", "eyre", "pulldown-cmark", "serde_json", @@ -611,7 +597,7 @@ name = "comline-doc-markdown" version = "0.1.0" source = "git+https://github.com/ComlineProject/generation?rev=da81b688c949a0ebad4f213d6fdb648920cf641d#da81b688c949a0ebad4f213d6fdb648920cf641d" dependencies = [ - "comline-codegen 0.1.0 (git+https://github.com/ComlineProject/generation?rev=da81b688c949a0ebad4f213d6fdb648920cf641d)", + "comline-codegen", "eyre", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 22f2e4c..46fc6f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,8 +59,8 @@ comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = # `comline-codegen`. comline-doc-markdown = { git = "https://github.com/ComlineProject/generation", rev = "da81b688c949a0ebad4f213d6fdb648920cf641d" } comline-doc-html = { git = "https://github.com/ComlineProject/generation", rev = "da81b688c949a0ebad4f213d6fdb648920cf641d" } -comline-codegen-rust = { git = "https://github.com/ComlineProject/comline-rust", rev = "df91e2e0a416cab594303f11d44a6555a72f891b", optional = true } -comline-codegen-typescript = { git = "https://github.com/ComlineProject/comline-typescript", rev = "8d829be859feac26d775f4877f098fedc38fdd9f", optional = true } +comline-codegen-rust = { git = "https://github.com/ComlineProject/comline-rust", rev = "6db2757b6d1e7df44df8c47adc8cad5bec1559c1", optional = true } +comline-codegen-typescript = { git = "https://github.com/ComlineProject/comline-typescript", rev = "bcec31dd13320613bcc1dcb10dcbc72f9a1011f9", optional = true } # `comline conformance`: the conformance runner (corpus loading, judging, # profile proofs) and its case format, a public spec. Pinned by git rev. comline-runtime-conformance = { git = "https://github.com/ComlineProject/runtime", rev = "8f8c0cb6fb0bc3a734aafbdbbf187fb9da73e00d" } From 41044bf99f34c19713ab910d789c7e54ee680478 Mon Sep 17 00:00:00 2001 From: Kinflou Date: Sun, 15 Nov 2026 03:23:20 +0800 Subject: [PATCH 4/4] Follow std's docs to reference/package/schema/std/ (generation#145); rustfmt the new tests --- docs/cli.md | 2 +- tests/cli/doc.rs | 2 +- tests/cli/generation.rs | 10 ++++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/cli.md b/docs/cli.md index 5b4db67..f27f469 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -704,7 +704,7 @@ formats = ["html", "markdown", "json"] versions = { last = 5 } # or "all" (the default), { since = "0.3.0" }, { releases_only = true } renderer = "renderers/my-renderer.wasm" # optional: an external renderer timeout = 60 # seconds per call to `renderer` -links = { std = "https://comlineproject.github.io/docs/reference/schema/std/" } +links = { std = "https://comlineproject.github.io/docs/reference/package/schema/std/" } changelog_from = "0.1.0" # with --version only ``` diff --git a/tests/cli/doc.rs b/tests/cli/doc.rs index bf18165..de52a08 100644 --- a/tests/cli/doc.rs +++ b/tests/cli/doc.rs @@ -574,7 +574,7 @@ fn dependencies_are_listed_apart_by_reach() { let api = read(&site.join("html/0.1.0-dev.1/api.html")); assert!( api.contains( - "href=\"https://comlineproject.github.io/docs/reference/schema/std/http/#httpmethod\"" + "href=\"https://comlineproject.github.io/docs/reference/package/schema/std/http/#httpmethod\"" ), "{api}" ); diff --git a/tests/cli/generation.rs b/tests/cli/generation.rs index a4a4046..64a7332 100644 --- a/tests/cli/generation.rs +++ b/tests/cli/generation.rs @@ -1467,12 +1467,10 @@ fn app_using_a_dependencys_types(root: &std::path::Path) -> std::path::PathBuf { .unwrap(); let app = fixture_project(root); - let config = fs::read_to_string(app.join("config.idp")) - .unwrap() - .replace( - "rust#1.85.0 = {}", - "rust#1.85.0 = {}\n typescript#5.0 = {}", - ); + let config = fs::read_to_string(app.join("config.idp")).unwrap().replace( + "rust#1.85.0 = {}", + "rust#1.85.0 = {}\n typescript#5.0 = {}", + ); fs::write(app.join("config.idp"), config).unwrap(); add_to_config( &app,