shine-cli 1.7.0

Give personal automation a reviewable lifecycle
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
use super::install::installed_source_commands;
use super::profile::{
    remove_managed_shell_profile, remove_path_from_shell_config, write_managed_shell_profile,
};
use super::report::{remove_report_summary_parts, unlink_report_summary_parts};
use crate::config::Config;
use crate::output;
use anyhow::{Context, Result, bail};
use std::ffi::OsStr;

pub async fn handle_uninstall(
    config: &Config,
    target: Option<&str>,
    purge: bool,
    dry_run: bool,
) -> Result<()> {
    crate::config::print_presets_note(config);
    if dry_run {
        println!(
            "{}",
            crate::colors::dim("[dry-run] No files will be modified.")
        );
    }
    let selection = target
        .map(super::metadata::parse_lifecycle_target)
        .transpose()?;
    if let Some(selection) = selection
        && let Some(command) = selection.command
    {
        return handle_uninstall_command(config, selection.category, command, purge, dry_run).await;
    }
    let category = selection.map(|selection| selection.category);

    // When a category is given, scope removal to that category's subdirectory.
    let managed_presets_root = match category {
        Some(cat) => config.presets_dir().join("shell").join(cat),
        None => config.presets_dir().to_path_buf(),
    };
    let managed_rendered_root = match category {
        Some(cat) => config.rendered_dir().join("shell").join(cat),
        None => config.rendered_dir().join("shell"),
    };
    let prefix = match category {
        Some(cat) => format!("shell/{cat}"),
        None => "shell".to_owned(),
    };

    // Remove symlinks pointing to presets_dir (old-style) or rendered_dir (new-style).
    let unlink_presets =
        crate::bin_links::unlink_managed(config.bin_dir(), &managed_presets_root, dry_run).await?;
    let unlink_rendered =
        crate::bin_links::unlink_managed(config.bin_dir(), &managed_rendered_root, dry_run).await?;
    let managed_installed_root = match category {
        Some(cat) => config.installed_shell_dir().join(cat),
        None => config.installed_shell_dir(),
    };
    let unlink_installed =
        crate::bin_links::unlink_managed(config.bin_dir(), &managed_installed_root, dry_run)
            .await?;
    let unlink_report = crate::bin_links::UnlinkReport {
        removed: [
            unlink_presets.removed,
            unlink_rendered.removed,
            unlink_installed.removed,
        ]
        .concat(),
        skipped: [
            unlink_presets.skipped,
            unlink_rendered.skipped,
            unlink_installed.skipped,
        ]
        .concat(),
    };
    output::summary_line("Bin Links", &unlink_report_summary_parts(&unlink_report));

    // When the user has a custom presets directory, the source files are theirs —
    // only remove the embedded-managed files when using the default directory.
    if !config.is_external_presets {
        let remove_report =
            crate::presets::remove_prefix(&prefix, config.presets_dir(), dry_run).await?;
        output::summary_line(
            "Shell Presets",
            &remove_report_summary_parts(&remove_report),
        );
    }

    // Only purge managed directories when using the default presets directory.
    // Never delete a user-configured external folder.
    if purge && !dry_run && !config.is_external_presets {
        let purge_dir = match category {
            Some(cat) => config.presets_dir().join("shell").join(cat),
            None => config.presets_dir().join("shell"),
        };
        if purge_dir.exists() {
            tokio::fs::remove_dir_all(&purge_dir)
                .await
                .with_context(|| format!("removing presets directory: {purge_dir:?}"))?;
        }
        if category.is_none() {
            // remove_dir only succeeds if empty — treat non-empty as benign
            let _ = tokio::fs::remove_dir(config.presets_dir()).await;
            let _ = tokio::fs::remove_dir(config.bin_dir()).await;
        }
        println!(
            "  {}  {}",
            crate::colors::symbol("✓"),
            crate::colors::dim("managed directories purged (if empty)"),
        );
    }

    // Remove rendered_dir files — always shine-managed regardless of external-presets mode.
    if !dry_run && managed_rendered_root.exists() {
        tokio::fs::remove_dir_all(&managed_rendered_root)
            .await
            .with_context(|| {
                format!("removing rendered dir: {}", managed_rendered_root.display())
            })?;
    }

    if !dry_run && managed_installed_root.exists() {
        tokio::fs::remove_dir_all(&managed_installed_root)
            .await
            .with_context(|| {
                format!(
                    "removing installed shell snapshot: {}",
                    managed_installed_root.display()
                )
            })?;
    }

    if !dry_run {
        let mut manifest = super::deployment::ShellManifest::load(config).await?;
        if let Some(category) = category {
            manifest.remove_category(category);
        } else {
            manifest.entries.clear();
        }
        manifest.save(config).await?;
    }

    if !dry_run {
        if category.is_none() {
            // Only remove the PATH sentinel when uninstalling all shell presets.
            remove_path_from_shell_config(config).await?;
            remove_managed_shell_profile(config).await?;
        } else {
            let remaining_source_commands = installed_source_commands(config).await?;
            write_managed_shell_profile(config, &remaining_source_commands).await?;
        }
    }

    Ok(())
}

async fn handle_uninstall_command(
    config: &Config,
    category: &str,
    command: &str,
    purge: bool,
    dry_run: bool,
) -> Result<()> {
    let mut manifest = super::deployment::ShellManifest::load(config).await?;
    let canonical = format!("shell/{category}/{command}");
    let manifest_entry = manifest.find(&canonical).cloned();
    let active_target = match super::metadata::load_active_target(
        config,
        super::metadata::ShellTarget {
            category,
            command: Some(command),
        },
    )
    .await
    {
        Ok(categories) => Some(categories),
        Err(error) if manifest_entry.is_none() => return Err(error),
        Err(_) => None,
    };

    let mut managed_roots = vec![
        config.presets_dir().join("shell").join(category),
        config.rendered_dir().join("shell").join(category),
        config.installed_shell_dir().join(category),
    ];
    if let Some(overlay) = config.active_presets_overlay_dir() {
        managed_roots.push(overlay.join("shell").join(category));
    }
    if let Some(entry) = &manifest_entry {
        // A live source or overlay may have moved since installation. The exact
        // recorded targets are still valid ownership evidence for removing this
        // launcher, without broadening removal to their user-owned parent tree.
        managed_roots.push(entry.source_path.clone());
        managed_roots.push(entry.rendered_path.clone());
    }
    let unlink_report = crate::bin_links::unlink_managed_command(
        config.bin_dir(),
        OsStr::new(command),
        &managed_roots,
        dry_run,
    )
    .await?;
    if manifest_entry.is_none() && unlink_report.removed.is_empty() {
        if unlink_report.skipped.is_empty() {
            bail!("shell command is not installed: {category}/{command}");
        }
        bail!(
            "shell command entry is not managed by Shine: {}",
            unlink_report.skipped[0].display()
        );
    }
    output::summary_line("Bin Links", &unlink_report_summary_parts(&unlink_report));

    let other_manifest_entry = manifest
        .entries
        .iter()
        .any(|entry| entry.category == category && entry.command != command);
    let other_link_exists =
        match super::metadata::load_active_categories(config, Some(category)).await {
            Ok(categories) => categories
                .iter()
                .flat_map(|category| &category.files)
                .any(|file| {
                    file.command_name != command
                        && crate::bin_links::command_path_for_name(
                            config.bin_dir(),
                            OsStr::new(&file.command_name),
                        )
                        .exists()
                }),
            Err(_) => false,
        };
    let category_still_installed = other_manifest_entry || other_link_exists;

    if !dry_run {
        let rendered_path = manifest_entry
            .as_ref()
            .map(|entry| entry.rendered_path.clone())
            .or_else(|| {
                active_target.and_then(|categories| {
                    categories.first().and_then(|category| {
                        category.files.first().map(|file| {
                            super::deployment::rendered_path(
                                config,
                                &category.name,
                                &file.source_rel,
                            )
                        })
                    })
                })
            });
        if let Some(path) = rendered_path
            && path.starts_with(config.rendered_dir())
            && !manifest.entries.iter().any(|entry| {
                (entry.category != category || entry.command != command)
                    && entry.rendered_path == path
            })
        {
            remove_file_if_present(&path).await?;
        }
        manifest.remove_target(category, command);
        manifest.save(config).await?;
    }

    if !category_still_installed {
        if !config.is_external_presets {
            let report = crate::presets::remove_prefix(
                &format!("shell/{category}"),
                config.presets_dir(),
                dry_run,
            )
            .await?;
            output::summary_line("Shell Presets", &remove_report_summary_parts(&report));
        }
        if !dry_run {
            remove_dir_if_present(&config.rendered_dir().join("shell").join(category)).await?;
            remove_dir_if_present(&config.installed_shell_dir().join(category)).await?;
        }
    }

    if purge && !dry_run && !config.is_external_presets && !category_still_installed {
        let _ = tokio::fs::remove_dir(config.presets_dir().join("shell")).await;
        let _ = tokio::fs::remove_dir(config.presets_dir()).await;
        let _ = tokio::fs::remove_dir(config.bin_dir()).await;
    }

    if !dry_run {
        let remaining_source_commands = installed_source_commands(config).await?;
        write_managed_shell_profile(config, &remaining_source_commands).await?;
    }
    Ok(())
}

async fn remove_file_if_present(path: &std::path::Path) -> Result<()> {
    match tokio::fs::remove_file(path).await {
        Ok(()) => Ok(()),
        Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(()),
        Err(error) => Err(error).with_context(|| format!("removing {}", path.display())),
    }
}

async fn remove_dir_if_present(path: &std::path::Path) -> Result<()> {
    match tokio::fs::remove_dir_all(path).await {
        Ok(()) => Ok(()),
        Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(()),
        Err(error) => Err(error).with_context(|| format!("removing {}", path.display())),
    }
}

#[cfg(test)]
mod tests {
    use super::super::ShellType;
    use super::super::install::handle_install;
    use super::super::profile::{append_path_to_shell_config, managed_shell_profile_path};
    use super::*;
    use std::path::PathBuf;
    use tokio::fs;

    async fn make_temp_dir() -> PathBuf {
        crate::test_support::make_temp_dir("shine-shell").await
    }

    #[tokio::test]
    async fn command_scoped_uninstall_preserves_installed_sibling() {
        let dir = make_temp_dir().await;
        let config = Config::new_for_test(&dir);
        fs::create_dir_all(config.bin_dir()).await.unwrap();

        handle_install(&config, Some("utils/shine-env-export"), false)
            .await
            .unwrap();
        handle_install(&config, Some("utils/shine-theme-sync"), false)
            .await
            .unwrap();
        handle_uninstall(&config, Some("utils/shine-env-export"), false, false)
            .await
            .unwrap();

        let removed = crate::bin_links::command_path_for_name(
            config.bin_dir(),
            std::ffi::OsStr::new("shine-env-export"),
        );
        let sibling = crate::bin_links::command_path_for_name(
            config.bin_dir(),
            std::ffi::OsStr::new("shine-theme-sync"),
        );
        assert!(!removed.exists());
        assert!(sibling.exists());

        let manifest = crate::shells::deployment::ShellManifest::load(&config)
            .await
            .unwrap();
        assert!(manifest.find("shell/utils/shine-env-export").is_none());
        assert!(manifest.find("shell/utils/shine-theme-sync").is_some());

        let profile = fs::read_to_string(managed_shell_profile_path(&config))
            .await
            .unwrap();
        assert!(!profile.contains(&wrapper_marker("shine-env-export", &config.shell_type)));
        assert!(profile.contains(&wrapper_marker("shine-theme-sync", &config.shell_type)));

        fs::remove_dir_all(&dir).await.unwrap();
    }

    #[tokio::test]
    async fn command_scoped_uninstall_preserves_shared_rendered_file() {
        let dir = make_temp_dir().await;
        let category = dir.join("presets/shell/custom");
        fs::create_dir_all(&category).await.unwrap();
        fs::write(
            category.join("shine.toml"),
            b"[[files]]\nsource = \"shared.sh\"\ntarget = \"one\"\ntransforms = [\"template\"]\n\n[[files]]\nsource = \"shared.sh\"\ntarget = \"two\"\ntransforms = [\"template\"]\n",
        )
        .await
        .unwrap();
        fs::write(category.join("shared.sh"), b"#!/bin/sh\necho shared\n")
            .await
            .unwrap();
        let mut config = Config::new_for_test(&dir);
        config.is_external_presets = true;
        fs::create_dir_all(config.bin_dir()).await.unwrap();

        handle_install(&config, Some("custom/one"), false)
            .await
            .unwrap();
        handle_install(&config, Some("custom/two"), false)
            .await
            .unwrap();
        let rendered = config.rendered_dir().join("shell/custom/shared.sh");
        assert!(rendered.exists());

        handle_uninstall(&config, Some("custom/one"), false, false)
            .await
            .unwrap();

        assert!(
            rendered.exists(),
            "installed sibling still uses rendered file"
        );
        assert!(config.bin_dir().join("two").exists());
        let manifest = crate::shells::deployment::ShellManifest::load(&config)
            .await
            .unwrap();
        assert!(manifest.find("shell/custom/one").is_none());
        assert_eq!(
            manifest.find("shell/custom/two").unwrap().rendered_path,
            rendered
        );

        fs::remove_dir_all(&dir).await.unwrap();
    }

    #[tokio::test]
    async fn command_scoped_uninstall_dry_run_preserves_launcher_and_manifest() {
        let dir = make_temp_dir().await;
        let config = Config::new_for_test(&dir);
        fs::create_dir_all(config.bin_dir()).await.unwrap();
        handle_install(&config, Some("utils/shine-env-export"), false)
            .await
            .unwrap();

        handle_uninstall(&config, Some("utils/shine-env-export"), false, true)
            .await
            .unwrap();

        let command = crate::bin_links::command_path_for_name(
            config.bin_dir(),
            std::ffi::OsStr::new("shine-env-export"),
        );
        assert!(command.exists());
        let manifest = crate::shells::deployment::ShellManifest::load(&config)
            .await
            .unwrap();
        assert!(manifest.find("shell/utils/shine-env-export").is_some());

        fs::remove_dir_all(&dir).await.unwrap();
    }

    #[tokio::test]
    async fn command_scoped_uninstall_preserves_foreign_command_entry() {
        let dir = make_temp_dir().await;
        let config = Config::new_for_test(&dir);
        fs::create_dir_all(config.bin_dir()).await.unwrap();
        handle_install(&config, Some("utils/shine-env-export"), false)
            .await
            .unwrap();
        let command = crate::bin_links::command_path_for_name(
            config.bin_dir(),
            std::ffi::OsStr::new("shine-env-export"),
        );
        crate::bin_links::unlink_managed_command(
            config.bin_dir(),
            std::ffi::OsStr::new("shine-env-export"),
            &[config.presets_dir().join("shell/utils")],
            false,
        )
        .await
        .unwrap();
        fs::write(&command, b"user-owned command\n").await.unwrap();

        handle_uninstall(&config, Some("utils/shine-env-export"), false, false)
            .await
            .unwrap();

        assert_eq!(
            fs::read_to_string(&command).await.unwrap(),
            "user-owned command\n"
        );
        let manifest = crate::shells::deployment::ShellManifest::load(&config)
            .await
            .unwrap();
        assert!(manifest.find("shell/utils/shine-env-export").is_none());

        fs::remove_dir_all(&dir).await.unwrap();
    }

    fn wrapper_marker(command: &str, shell: &ShellType) -> String {
        match shell {
            ShellType::PowerShell => format!("\nfunction {command} {{ . (Join-Path $shineBin"),
            ShellType::Fish => format!("\nfunction {command}"),
            _ => format!("\n{command}() {{ source"),
        }
    }

    #[cfg(unix)]
    #[tokio::test]
    async fn uninstall_purge_removes_managed_dirs_but_not_config() {
        let dir = make_temp_dir().await;
        let config = Config::new_for_test(&dir);
        fs::create_dir_all(config.presets_dir()).await.unwrap();
        fs::create_dir_all(config.bin_dir()).await.unwrap();

        handle_install(&config, None, false).await.unwrap();
        handle_uninstall(&config, None, true, false).await.unwrap();

        assert!(!config.bin_dir().exists(), "bin_dir should be purged");
        assert!(
            !config.presets_dir().join("shell").exists(),
            "shell presets dir should be purged"
        );
        // config.toml must never be removed by uninstall
        assert!(
            config.presets_dir().parent().is_some(),
            "shine root still accessible"
        );

        fs::remove_dir_all(&dir).await.unwrap();
    }

    #[cfg(unix)]
    #[tokio::test]
    async fn uninstall_dry_run_leaves_everything_intact() {
        let dir = make_temp_dir().await;
        let config = Config::new_for_test(&dir);
        fs::create_dir_all(config.presets_dir()).await.unwrap();
        fs::create_dir_all(config.bin_dir()).await.unwrap();

        handle_install(&config, None, false).await.unwrap();
        let preset_path = config.presets_dir().join("shell/proxy/set_proxy.sh");
        assert!(preset_path.exists());

        handle_uninstall(&config, None, false, true).await.unwrap();

        assert!(preset_path.exists(), "dry-run must not remove preset files");

        fs::remove_dir_all(&dir).await.unwrap();
    }

    #[tokio::test]
    async fn remove_clears_sentinel_from_shell_config() {
        let dir = make_temp_dir().await;
        let config = Config::new_for_test(&dir);

        append_path_to_shell_config(&config, false, &[])
            .await
            .unwrap();
        remove_path_from_shell_config(&config).await.unwrap();

        let config_path =
            super::super::get_shell_config_path(&config.shell_type, &config.home_dir).unwrap();
        let content = fs::read_to_string(&config_path).await.unwrap();
        assert!(
            !content.contains(super::super::SENTINEL_START),
            "sentinel should be gone after remove"
        );
    }

    #[tokio::test]
    async fn remove_is_no_op_when_config_missing() {
        let dir = make_temp_dir().await;
        let config = Config::new_for_test(&dir);
        // No install — config file doesn't exist
        remove_path_from_shell_config(&config).await.unwrap();
    }

    #[cfg(unix)]
    #[tokio::test]
    async fn uninstall_dry_run_does_not_modify_shell_config() {
        let dir = make_temp_dir().await;
        let config = Config::new_for_test(&dir);
        fs::create_dir_all(config.presets_dir()).await.unwrap();
        fs::create_dir_all(config.bin_dir()).await.unwrap();

        handle_install(&config, None, false).await.unwrap();
        let config_path =
            super::super::get_shell_config_path(&config.shell_type, &config.home_dir).unwrap();
        let before = fs::read_to_string(&config_path).await.unwrap();
        let profile_path = managed_shell_profile_path(&config);
        let profile_before = fs::read_to_string(&profile_path).await.unwrap();

        handle_uninstall(&config, None, false, true).await.unwrap();

        let after = fs::read_to_string(&config_path).await.unwrap();
        assert_eq!(before, after, "dry-run must not touch shell config");
        let profile_after = fs::read_to_string(&profile_path).await.unwrap();
        assert_eq!(
            profile_before, profile_after,
            "dry-run must not touch managed shell profile"
        );

        fs::remove_dir_all(&dir).await.unwrap();
    }

    #[tokio::test]
    async fn uninstall_category_keeps_agent_launcher_and_prunes_source_wrappers() {
        let dir = make_temp_dir().await;
        let config = Config::new_for_test(&dir);
        fs::create_dir_all(config.presets_dir()).await.unwrap();
        fs::create_dir_all(config.bin_dir()).await.unwrap();

        handle_install(&config, Some("agent"), false).await.unwrap();
        handle_install(&config, Some("proxy"), false).await.unwrap();

        handle_uninstall(&config, Some("proxy"), false, false)
            .await
            .unwrap();

        let profile = fs::read_to_string(managed_shell_profile_path(&config))
            .await
            .unwrap();
        assert!(!profile.contains(&wrapper_marker("ccenv", &config.shell_type)));
        assert!(
            !profile.contains(&wrapper_marker("setproxy", &config.shell_type)),
            "removed category wrapper should be pruned: {profile}"
        );
        assert!(
            !profile.contains(&wrapper_marker("usetproxy", &config.shell_type)),
            "removed category wrapper should be pruned: {profile}"
        );
        let ccenv = crate::bin_links::command_path_for_name(
            config.bin_dir(),
            std::ffi::OsStr::new("ccenv"),
        );
        assert!(ccenv.exists(), "remaining Bun launcher should be kept");

        fs::remove_dir_all(&dir).await.unwrap();
    }

    #[cfg(unix)]
    #[tokio::test]
    async fn external_presets_uninstall_preserves_disk_scripts() {
        let dir = make_temp_dir().await;
        let cat_dir = dir.join("presets/shell/custom");
        fs::create_dir_all(&cat_dir).await.unwrap();
        let script = cat_dir.join("my_tool.sh");
        fs::write(&script, b"#!/bin/bash\n# My tool.\necho hi\n")
            .await
            .unwrap();
        use std::os::unix::fs::PermissionsExt;
        let mut perms = fs::metadata(&script).await.unwrap().permissions();
        perms.set_mode(perms.mode() | 0o111);
        fs::set_permissions(&script, perms).await.unwrap();

        let mut config = Config::new_for_test(&dir);
        config.is_external_presets = true;
        fs::create_dir_all(config.bin_dir()).await.unwrap();

        handle_install(&config, Some("custom"), false)
            .await
            .unwrap();
        assert!(config.bin_dir().join("my_tool").exists());

        handle_uninstall(&config, Some("custom"), false, false)
            .await
            .unwrap();

        // User-owned script must survive uninstall.
        assert!(script.exists(), "user script must not be deleted");
        // Bin symlink should be gone.
        assert!(
            !config.bin_dir().join("my_tool").exists(),
            "bin link should be removed"
        );

        fs::remove_dir_all(&dir).await.unwrap();
    }
}