Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Developer lists what rustup downloaded

Țugui Dragoșce0c34ca8273
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
index a5f93a12..395e9c5e 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
@@ -459,6 +459,10 @@ public enum DeveloperCaches {
Folder(".pyenv/cache", .downloads, source: "https://github.com/pyenv/pyenv/blob/master/plugins/python-build/bin/pyenv-install#L235-L238"),
]),
// Rust and Go
+ // Only what rustup downloaded, which `rustup update` empties itself, never the toolchains it installed.
+ Definition(id: "rustup", name: "rustup", systemImage: "gearshape.2", appBundleIdentifiers: [], folders: [
+ Folder(".rustup/downloads", .downloads, source: "https://github.com/rust-lang/rustup/blob/master/src/cli/rustup_mode.rs#L1203-L1205"),
+ ]),
Definition(id: "cargo", name: "Cargo", systemImage: "gearshape.2", appBundleIdentifiers: [], folders: [
Folder(".cargo/registry/cache", .downloads, source: "https://github.com/rust-lang/cargo/blob/master/doc/book/src/guide/cargo-home.md#L47-L48"),
Folder(".cargo/registry/index", .downloads, source: "https://github.com/rust-lang/cargo/blob/master/doc/book/src/guide/cargo-home.md#L44-L45"),
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
index bd6e734a..c0f129c3 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
@@ -235,7 +235,7 @@ struct DeveloperCachesTests {
/// Toolchains, environments, and anything holding an account are installations or secrets, not caches.
@Test func neverListsToolchainsOrCredentials() {
let forbidden = [
- ".rustup", ".sdkman", ".jenv", "nix/store", ".nix-profile", ".asdf", ".volta",
+ ".sdkman", ".jenv", "nix/store", ".nix-profile", ".asdf", ".volta",
"conda/envs", "miniconda3/envs", "anaconda3/envs", ".local/pipx",
"Library/Android/sdk", "flutter/bin", ".stack/programs",
".aws", ".ssh", ".gnupg", ".netrc", ".docker/config", ".kube/config", ".npmrc",
@@ -267,11 +267,11 @@ struct DeveloperCachesTests {
"Library/Unity",
]
// CocoaPods' spec repositories hold the ones a person added, which can carry unpushed work: only the CDN copy
- // of the public index, `trunk`, is a cache. nvm's, pyenv's and rbenv's folders hold every version they
- // installed; only their download caches are caches.
+ // of the public index, `trunk`, is a cache. nvm's, pyenv's, rbenv's and rustup's folders hold every version
+ // they installed; only their download caches are caches.
let onlyThisPart = [
".cocoapods/repos": ".cocoapods/repos/trunk", ".nvm": ".nvm/.cache", ".pyenv": ".pyenv/cache",
- ".rbenv": ".rbenv/cache",
+ ".rbenv": ".rbenv/cache", ".rustup": ".rustup/downloads",
]
for definition in DeveloperCaches.definitions {
for path in definition.folders.map(\.path) {
@@ -769,6 +769,17 @@ struct DeveloperCachesTests {
#expect(Set(locations.map(\.url.lastPathComponent)) == ["notifications", "workers"])
}
+ @Test func offersWhatRustupDownloadedAndNeverItsToolchains() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file(".rustup/downloads/4b1c.partial", bytes: 400_000)
+ try directory.file(".rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc", bytes: 400_000)
+ let rustup = DeveloperCaches.definitions.filter { $0.id == "rustup" }
+
+ let locations = await DeveloperCaches.scan(rustup, homeDirectory: directory.url).flatMap(\.locations)
+
+ #expect(locations.map(\.url.lastPathComponent) == ["downloads"])
+ }
+
/// virtualenvwrapper keeps the user's hook scripts beside the environments in `~/.virtualenvs`, so only the
/// environments are offered, and a link among them is left where it is, never followed.
@Test func offersVirtualenvwrappersEnvironmentsAndNotItsHooks() async throws {