mise-util 2026.11.14

Environment, directory, and filesystem helpers shared by mise's crates
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
//! Host requirements describe prerequisites, not dependencies to install.
use std::cmp::Ordering;
use std::collections::{BTreeMap, BTreeSet};
use std::path::PathBuf;

use eyre::{Result, bail};
use packslip::model::Artifact;

use crate::cmd::CmdLineRunner;
use crate::file;

#[derive(Debug, Default)]
pub struct Report {
    pub failures: Vec<String>,
    pub warnings: Vec<String>,
}

impl Report {
    pub fn enforce(&self, ignore: bool) -> Result<()> {
        for warning in &self.warnings {
            warn!("packslip requirement: {warning}");
        }
        if self.failures.is_empty() {
            return Ok(());
        }
        let failures = self.failures.join("; ");
        if ignore {
            warn!("overriding packslip host requirements: {failures}");
            Ok(())
        } else {
            bail!(
                "packslip host requirements not met: {failures}; set ignore_requirements=true for this tool to override"
            )
        }
    }
}

/// Compare arbitrarily large numeric components without overflow or semver.
fn numeric_cmp(actual: &str, min: &str) -> Option<Ordering> {
    fn parts(s: &str) -> Option<Vec<&str>> {
        s.split('.')
            .map(|p| {
                if p.is_empty() || !p.bytes().all(|c| c.is_ascii_digit()) {
                    return None;
                }
                let p = p.trim_start_matches('0');
                Some(if p.is_empty() { "0" } else { p })
            })
            .collect()
    }
    let a = parts(actual)?;
    let b = parts(min)?;
    for i in 0..a.len().max(b.len()) {
        let a = a.get(i).copied().unwrap_or("0");
        let b = b.get(i).copied().unwrap_or("0");
        let cmp = a.len().cmp(&b.len()).then_with(|| a.cmp(b));
        if cmp != Ordering::Equal {
            return Some(cmp);
        }
    }
    Some(Ordering::Equal)
}

pub fn meets_minimum(actual: &str, min: &str) -> Option<bool> {
    numeric_cmp(actual, min).map(|ordering| ordering != Ordering::Less)
}

fn version_from_output(output: &str) -> Option<String> {
    let words: Vec<_> = output
        .split_whitespace()
        .map(|s| s.trim_matches(['"', '\'', '(', ')', '[', ']']))
        .collect();
    let candidate = if let Some(i) = words.iter().position(|s| s.eq_ignore_ascii_case("version")) {
        words.get(i + 1)?
    } else if words.len() == 1 {
        words.first()?
    } else {
        // Conventional `tool VERSION ...`, never a later build date that
        // happens to be numeric when the version token was unrecognized.
        words.get(1)?
    };
    numeric_cmp(candidate, "0").map(|_| (*candidate).to_owned())
}

/// The most output a version probe may print.
const PROBE_LIMIT: usize = 64 * 1024;

async fn probe(program: &str, args: &[&str]) -> Option<String> {
    probe_with_limit(program, args, PROBE_LIMIT).await
}

async fn probe_with_limit(program: &str, args: &[&str], limit: usize) -> Option<String> {
    CmdLineRunner::new(program)
        .args(args)
        .read_isolated(limit)
        .await
        .ok()
}

pub async fn glibc_version() -> Option<String> {
    if !cfg!(target_os = "linux") {
        return None;
    }
    probe("getconf", &["GNU_LIBC_VERSION"])
        .await
        .as_deref()
        .and_then(version_from_output)
}

/// `uname -r` reports a release, not a version: `6.8.0-31-generic` on one
/// distribution and `6.6.87.2-microsoft-standard-WSL2` on another. What
/// follows the dotted numbers is the distribution's own business, and an
/// `os_min` is a lower bound on the numbers, so read those and stop.
///
/// Windows reads its version from a sentence `ver` prints, so nothing there
/// calls this and the compiler would rightly call it dead.
#[cfg(not(windows))]
fn release_version(output: &str) -> Option<String> {
    let word = output.split_whitespace().next()?;
    let end = word
        .find(|c: char| !c.is_ascii_digit() && c != '.')
        .unwrap_or(word.len());
    let version = word[..end].trim_end_matches('.');
    numeric_cmp(version, "0").map(|_| version.to_owned())
}

async fn os_version() -> Option<String> {
    #[cfg(target_os = "macos")]
    let version = probe("/usr/bin/sw_vers", &["-productVersion"])
        .await
        .as_deref()
        .and_then(release_version);
    // `Microsoft Windows [Version 10.0.19045.5011]`, so read it by the word.
    #[cfg(windows)]
    let version = probe("cmd.exe", &["/D", "/C", "ver"])
        .await
        .as_deref()
        .and_then(version_from_output);
    #[cfg(not(any(target_os = "macos", windows)))]
    let version = probe("uname", &["-r"])
        .await
        .as_deref()
        .and_then(release_version);
    version
}

/// The loader cache's names, read at most once per [`check_host`]: the
/// manifest decides how many libraries are asked about, and `ldconfig -p`
/// gives the same answer for all of them. `None` inside means it could not
/// be read.
type LoaderCache = tokio::sync::OnceCell<Option<BTreeSet<String>>>;

/// The most `ldconfig -p` may print. It writes a line of about 100 bytes for
/// every library the loader knows, and a desktop install knows thousands: at
/// the version probes' 64 KiB the cache of such a host could not be read, so
/// every library it was asked about was reported as unknown.
#[cfg(target_os = "linux")]
const LOADER_CACHE_LIMIT: usize = 16 * 1024 * 1024;

/// The names in the loader cache `ldconfig` prints, or `None` if it could
/// not be read.
#[cfg(target_os = "linux")]
async fn read_loader_cache(ldconfig: &str) -> Option<BTreeSet<String>> {
    let cache = probe_with_limit(ldconfig, &["-p"], LOADER_CACHE_LIMIT).await?;
    Some(loader_cache_names(&cache))
}

/// The directories the loader searches by default, checked before the
/// loader cache is read. Debian and Ubuntu keep libraries in a directory
/// named for the architecture's multiarch tuple.
#[cfg(target_os = "linux")]
fn default_library_dirs() -> Vec<PathBuf> {
    let mut dirs: Vec<PathBuf> = ["/lib", "/lib64", "/usr/lib", "/usr/lib64"]
        .map(PathBuf::from)
        .into();
    for tuple in multiarch_tuples(std::env::consts::ARCH, cfg!(target_endian = "little")) {
        dirs.push(PathBuf::from("/lib").join(tuple));
        dirs.push(PathBuf::from("/usr/lib").join(tuple));
    }
    dirs
}

/// Debian's multiarch tuples for a Rust architecture. They are not
/// `<arch>-linux-gnu` throughout: 32-bit ARM names its float ABI, x86 is
/// `i386`, and 64-bit POWER names its byte order, which `ARCH` leaves out.
/// Both ARM ABIs are listed, since a directory that is not there costs
/// nothing.
#[cfg(target_os = "linux")]
fn multiarch_tuples(arch: &str, little_endian: bool) -> &'static [&'static str] {
    match arch {
        "x86_64" => &["x86_64-linux-gnu"],
        "x86" => &["i386-linux-gnu"],
        "aarch64" => &["aarch64-linux-gnu"],
        "arm" => &["arm-linux-gnueabihf", "arm-linux-gnueabi"],
        "riscv64" => &["riscv64-linux-gnu"],
        "powerpc64" if little_endian => &["powerpc64le-linux-gnu"],
        "powerpc64" => &["powerpc64-linux-gnu"],
        "s390x" => &["s390x-linux-gnu"],
        "loongarch64" => &["loongarch64-linux-gnu"],
        "mips64" if little_endian => &["mips64el-linux-gnuabi64"],
        _ => &[],
    }
}

/// The names `ldconfig -p` resolves to an existing file of this
/// architecture.
#[cfg(target_os = "linux")]
fn loader_cache_names(cache: &str) -> BTreeSet<String> {
    let arch = std::env::consts::ARCH;
    cache
        .lines()
        .filter(|line| {
            let native = match arch {
                "x86_64" => line.contains("x86-64"),
                "aarch64" => line.contains("AArch64"),
                _ => true,
            };
            native
                && line
                    .split("=>")
                    .nth(1)
                    .is_some_and(|p| std::path::Path::new(p.trim()).is_file())
        })
        .filter_map(|line| line.split_whitespace().next())
        .map(str::to_owned)
        .collect()
}

async fn library_present(name: &str, loader_cache: &LoaderCache) -> Option<bool> {
    if !file::is_plain_file_name(name) {
        return None;
    }
    // Only Linux has a loader cache to read.
    #[cfg(not(target_os = "linux"))]
    let _ = loader_cache;
    #[cfg(target_os = "linux")]
    {
        let mut paths: Vec<PathBuf> = std::env::var_os("LD_LIBRARY_PATH")
            .map(|p| std::env::split_paths(&p).collect())
            .unwrap_or_default();
        paths.extend(default_library_dirs());
        if paths.iter().any(|p| p.join(name).is_file()) {
            return Some(true);
        }
        // Cache failure is unknown, not proof of absence. The cache normally
        // covers distribution-specific multiarch directories as well.
        let names = loader_cache
            .get_or_init(|| read_loader_cache("/sbin/ldconfig"))
            .await;
        Some(names.as_ref()?.contains(name))
    }
    #[cfg(target_os = "macos")]
    {
        let mut paths: Vec<PathBuf> = std::env::var_os("DYLD_LIBRARY_PATH")
            .map(|p| std::env::split_paths(&p).collect())
            .unwrap_or_default();
        paths.extend(["/usr/local/lib", "/usr/lib", "/opt/homebrew/lib"].map(PathBuf::from));
        if paths.iter().any(|p| p.join(name).is_file()) {
            return Some(true);
        }
        // The dyld shared cache can contain libraries without filesystem
        // entries. Without querying it we cannot establish absence.
        None
    }
    #[cfg(windows)]
    {
        let mut paths: Vec<PathBuf> =
            std::env::split_paths(&std::env::var_os("PATH").unwrap_or_default()).collect();
        if let Some(root) = std::env::var_os("SystemRoot") {
            paths.push(PathBuf::from(root).join("System32"));
        }
        Some(paths.iter().any(|p| p.join(name).is_file()))
    }
    #[cfg(not(any(target_os = "linux", target_os = "macos", windows)))]
    {
        None
    }
}

fn check_min(report: &mut Report, label: &str, actual: Option<&str>, min: &str, fatal: bool) {
    match actual.and_then(|actual| numeric_cmp(actual, min)) {
        Some(Ordering::Less) => {
            let message = format!("{label} {} is below required {min}", actual.unwrap());
            if fatal {
                report.failures.push(message);
            } else {
                report.warnings.push(message);
            }
        }
        Some(_) => {}
        None => report.warnings.push(format!("cannot check {label}>={min}")),
    }
}

/// The command to start for a `--version` probe, and the directory to start
/// it in: the command's own. A command found through a relative `PATH` entry
/// such as `./bin` is relative to mise's working directory, so it is made
/// absolute first, or it would not be found from its own directory.
fn probe_location(path: PathBuf) -> (PathBuf, PathBuf) {
    let path = std::path::absolute(&path).unwrap_or(path);
    let dir = path
        .parent()
        .filter(|dir| dir.is_absolute())
        .map(PathBuf::from)
        .unwrap_or_else(std::env::temp_dir);
    (path, dir)
}

/// Everything that can fail an artifact: the OS, glibc and shared
/// libraries. It starts only fixed system programs, never one the manifest
/// names, so resolving a version can call it for a manifest that config
/// nobody trusted points at.
pub async fn check_host(artifact: &Artifact) -> Report {
    let mut report = Report::default();
    let Some(req) = &artifact.requires else {
        return report;
    };
    if let Some(min) = &req.os_min {
        check_min(&mut report, "OS", os_version().await.as_deref(), min, true);
    }
    if let Some(min) = &req.glibc_min {
        let glibc = glibc_version().await;
        check_min(&mut report, "glibc", glibc.as_deref(), min, true);
    }
    let loader_cache = LoaderCache::new();
    for lib in req.libs.iter().flatten() {
        match library_present(lib, &loader_cache).await {
            Some(true) => {}
            Some(false) => report.failures.push(format!(
                "shared library {lib} was not found by the host loader search"
            )),
            None => report
                .warnings
                .push(format!("cannot check shared library {lib}")),
        }
    }
    report
}

/// [`check_host`], and every command the manifest requires, each started
/// with `--version` when it names a minimum. A command can only add a
/// warning, so only an install, about to use the artifact, calls this.
/// `commands` contains paths resolved from the install's active mise toolset.
/// Ambient PATH supplies commands not managed by that toolset.
pub async fn check(artifact: &Artifact, commands: &BTreeMap<String, PathBuf>) -> Report {
    let mut report = check_host(artifact).await;
    let Some(req) = &artifact.requires else {
        return report;
    };
    for bin in &req.bin {
        let path = commands
            .get(&bin.name)
            .cloned()
            // `which` matches the bare name, so on Windows `git.exe` and
            // `node.cmd` read as missing; `which_spawnable` applies PATHEXT
            // and only offers a path the OS will start.
            .or_else(|| file::which_spawnable(&bin.name));
        let Some(path) = path else {
            report.warnings.push(format!(
                "command {}{} is missing; install it before using features that need it",
                bin.name,
                bin.min
                    .as_deref()
                    .map(|v| format!(">={v}"))
                    .unwrap_or_default()
            ));
            continue;
        };
        if let Some(min) = &bin.min {
            // Beside the command, not in the user's project: the manifest
            // picks the command, and some (rustup's proxies, yarn, mvn) load
            // code that files in the working directory name even for
            // `--version`. Whoever can write beside the command could
            // already replace it.
            let (path, dir) = probe_location(path);
            let output = CmdLineRunner::new(path)
                .current_dir(dir)
                .arg("--version")
                .env("MISE_AUTO_INSTALL", "0")
                .read_isolated(64 * 1024)
                .await
                .ok();
            let version = output.as_deref().and_then(version_from_output);
            check_min(&mut report, &bin.name, version.as_deref(), min, false);
        }
    }
    report
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn lower_bounds_are_numeric_and_unknown_is_a_warning() {
        for (a, b, order) in [
            ("21", "17", Ordering::Greater),
            ("2.10", "2.9", Ordering::Greater),
            ("17", "17.0.0", Ordering::Equal),
            ("0002.09", "2.9", Ordering::Equal),
            ("999999999999999999999999999999", "21", Ordering::Greater),
        ] {
            assert_eq!(numeric_cmp(a, b), Some(order));
        }
        for bad in ["", "v2.0", "2.1-rc1", "2..0", "-1"] {
            assert_eq!(numeric_cmp(bad, "1"), None);
        }
        let mut r = Report::default();
        check_min(&mut r, "OS", Some("12"), "13", true);
        check_min(&mut r, "java", Some("11"), "17", false);
        check_min(&mut r, "glibc", None, "2.31", true);
        assert_eq!(r.failures.len(), 1);
        assert_eq!(r.warnings.len(), 2);
        assert!(r.enforce(false).is_err());
        assert!(r.enforce(true).is_ok());
        assert_eq!(
            version_from_output("openjdk version \"21.0.4\""),
            Some("21.0.4".into())
        );
        assert_eq!(
            version_from_output("git version 2.49.0"),
            Some("2.49.0".into())
        );
        // A kernel release carries a suffix; an `os_min` bounds the numbers.
        #[cfg(not(windows))]
        for (release, version) in [
            ("6.8.0-31-generic", Some("6.8.0")),
            ("6.6.87.2-microsoft-standard-WSL2", Some("6.6.87.2")),
            ("5.15", Some("5.15")),
            ("15.5", Some("15.5")),
            ("14.3-RELEASE-p5", Some("14.3")),
            ("-broken", None),
            ("", None),
        ] {
            assert_eq!(
                release_version(release).as_deref(),
                version,
                "reading {release:?}"
            );
        }
        assert_eq!(version_from_output("tool v1.2 built 2026"), None);
        assert_eq!(version_from_output("openjdk 21-ea 2026-09-04"), None);
    }

    #[cfg(target_os = "linux")]
    #[tokio::test]
    async fn the_loader_cache_is_read_once_for_every_library() {
        let exe = std::env::current_exe().unwrap();
        let exe = exe.display();
        let names = loader_cache_names(&format!(
            "3 libs found in cache `/etc/ld.so.cache'\n\
             \tlibhere.so.1 (libc6,x86-64,AArch64) => {exe}\n\
             \tlibgone.so.1 (libc6,x86-64,AArch64) => {exe}.gone\n\
             \tlibother.so.1 (libc6,other) => {exe}\n"
        ));
        assert!(names.contains("libhere.so.1"));
        assert!(!names.contains("libgone.so.1"));
        if matches!(std::env::consts::ARCH, "x86_64" | "aarch64") {
            assert_eq!(names.len(), 1);
        }

        // What the cache already holds answers; `ldconfig` is not run again
        // for each name the manifest lists.
        let cache = LoaderCache::new_with(Some(Some(names)));
        assert_eq!(library_present("libhere.so.1", &cache).await, Some(true));
        assert_eq!(library_present("libgone.so.1", &cache).await, Some(false));
        // A cache that could not be read stays unknown for every name.
        let unread = LoaderCache::new_with(Some(None));
        assert_eq!(library_present("libhere.so.1", &unread).await, None);
    }

    /// A desktop's loader cache, thousands of lines long, is read whole: at
    /// a 64 KiB bound it was not, and every library came back unknown.
    #[cfg(target_os = "linux")]
    #[tokio::test]
    async fn a_large_loader_cache_is_read() {
        let dir = tempfile::tempdir().unwrap();
        let exe = std::env::current_exe().unwrap();
        let mut cache = String::from("5001 libs found in cache `/etc/ld.so.cache'\n");
        for i in 0..5000 {
            cache.push_str(&format!(
                "\tlibfiller{i}.so.1 (libc6,x86-64,AArch64) => {}\n",
                exe.display()
            ));
        }
        cache.push_str(&format!(
            "\tlibudev.so.1 (libc6,x86-64,AArch64) => {}\n",
            exe.display()
        ));
        assert!(cache.len() > PROBE_LIMIT, "{}", cache.len());
        let listing = dir.path().join("ldconfig.out");
        std::fs::write(&listing, cache).unwrap();
        let ldconfig = dir.path().join("ldconfig");
        std::fs::write(
            &ldconfig,
            format!("#!/bin/sh\ncat '{}'\n", listing.display()),
        )
        .unwrap();
        file::make_executable(&ldconfig).unwrap();

        let names = read_loader_cache(&ldconfig.to_string_lossy())
            .await
            .expect("the loader cache should be readable");
        if matches!(std::env::consts::ARCH, "x86_64" | "aarch64") {
            assert!(names.contains("libudev.so.1"));
        }
    }

    #[cfg(target_os = "linux")]
    #[test]
    fn the_multiarch_directories_are_searched() {
        assert_eq!(multiarch_tuples("x86_64", true), ["x86_64-linux-gnu"]);
        assert_eq!(multiarch_tuples("x86", true), ["i386-linux-gnu"]);
        assert_eq!(multiarch_tuples("aarch64", true), ["aarch64-linux-gnu"]);
        assert_eq!(
            multiarch_tuples("arm", true),
            ["arm-linux-gnueabihf", "arm-linux-gnueabi"]
        );
        assert_eq!(
            multiarch_tuples("powerpc64", true),
            ["powerpc64le-linux-gnu"]
        );
        assert_eq!(
            multiarch_tuples("powerpc64", false),
            ["powerpc64-linux-gnu"]
        );
        assert!(multiarch_tuples("wasm32", true).is_empty());

        // This host's own tuple is searched under both /lib and /usr/lib.
        let dirs = default_library_dirs();
        for tuple in multiarch_tuples(std::env::consts::ARCH, cfg!(target_endian = "little")) {
            assert!(dirs.contains(&PathBuf::from("/usr/lib").join(tuple)));
            assert!(dirs.contains(&PathBuf::from("/lib").join(tuple)));
        }
    }

    #[cfg(unix)]
    #[tokio::test]
    async fn required_commands_run_only_for_an_install_and_outside_the_project() {
        let dir = tempfile::tempdir().unwrap();
        let dir = dir.path().canonicalize().unwrap();
        let tool = dir.join("tool");
        let ran_in = dir.join("ran-in");
        let script = "#!/bin/sh\npwd -P > \"${0%/*}/ran-in\"\necho tool 1.0\n";
        file::write(&tool, script).unwrap();
        file::make_executable(&tool).unwrap();
        let artifact: Artifact = serde_json::from_value(serde_json::json!({
            "name": "a.tar.gz", "size": 1, "format": "tar.gz",
            "requires": {"bin": [{"name": "tool", "min": "2"}]},
        }))
        .unwrap();

        // What resolution asks starts nothing the manifest names.
        let report = check_host(&artifact).await;
        assert!(report.failures.is_empty() && report.warnings.is_empty());
        assert!(!ran_in.exists());

        // An install does, beside the command rather than where mise runs.
        let report = check(&artifact, &BTreeMap::from([("tool".into(), tool.clone())])).await;
        assert!(report.failures.is_empty());
        assert_eq!(report.warnings, ["tool 1.0 is below required 2"]);
        assert_eq!(
            file::read_to_string(&ran_in).unwrap().trim_end(),
            dir.to_str().unwrap()
        );

        // A command found through a relative PATH entry, such as `./bin`, is
        // relative to where mise runs: it is still found from its own
        // directory, and its version still read.
        file::remove_file(&ran_in).unwrap();
        let cwd = std::env::current_dir().unwrap();
        let up = "../".repeat(cwd.components().count() - 1);
        let relative = PathBuf::from(up).join(tool.strip_prefix("/").unwrap());
        assert!(relative.is_relative() && relative.is_file(), "{relative:?}");
        let report = check(&artifact, &BTreeMap::from([("tool".into(), relative)])).await;
        assert_eq!(report.warnings, ["tool 1.0 is below required 2"]);
        assert_eq!(
            file::read_to_string(&ran_in).unwrap().trim_end(),
            dir.to_str().unwrap()
        );
    }
}