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 the package files pyenv and rbenv keep

Țugui Dragoșf1b29caea2af
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
index 43732e39..e92389b8 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
@@ -451,6 +451,10 @@ public enum DeveloperCaches {
Folder("Library/Caches/Jedi", .cache, source: "https://github.com/davidhalter/jedi/blob/master/jedi/settings.py#L77-L78"),
Folder("Library/Caches/Parso", .cache, source: "https://github.com/davidhalter/parso/blob/master/parso/cache.py#L69-L70"),
]),
+ // Only the package files `pyenv install` keeps, never `versions`, the Pythons it installed.
+ Definition(id: "pyenv", name: "pyenv", systemImage: "chevron.left.forwardslash.chevron.right", appBundleIdentifiers: [], folders: [
+ Folder(".pyenv/cache", .downloads, source: "https://github.com/pyenv/pyenv/blob/master/plugins/python-build/bin/pyenv-install#L235-L238"),
+ ]),
// Rust and Go
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"),
@@ -517,6 +521,10 @@ public enum DeveloperCaches {
Folder(".bundle/cache", .downloads, source: "https://github.com/ruby/rubygems/blob/master/lib/bundler.rb#L284-L303"),
Folder(".local/share/gem/ruby/*/cache", .downloads, source: "https://github.com/ruby/rubygems/blob/master/lib/rubygems/defaults.rb#L103-L109"),
]),
+ // Only the package files `rbenv install` keeps, never `versions`, the Rubies it installed.
+ Definition(id: "rbenv", name: "rbenv", systemImage: "shippingbox", appBundleIdentifiers: [], folders: [
+ Folder(".rbenv/cache", .downloads, source: "https://github.com/rbenv/ruby-build/blob/master/bin/rbenv-install#L209-L212"),
+ ]),
Definition(id: "nuget", name: "NuGet", systemImage: "shippingbox", appBundleIdentifiers: [], folders: [
Folder(".nuget/packages", .downloads, source: "https://github.com/NuGet/docs.microsoft.com-nuget/blob/main/docs/consume-packages/managing-the-global-packages-and-cache-folders.md#L17"),
Folder(".local/share/NuGet/v3-cache", .cache, source: "https://github.com/NuGet/docs.microsoft.com-nuget/blob/main/docs/consume-packages/managing-the-global-packages-and-cache-folders.md#L18"),
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
index 79c0aa7f..d3675c1a 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
@@ -234,7 +234,7 @@ struct DeveloperCachesTests {
/// Toolchains, environments, and anything holding an account are installations or secrets, not caches.
@Test func neverListsToolchainsOrCredentials() {
let forbidden = [
- ".rustup", ".pyenv", ".sdkman", ".rbenv", ".jenv", "nix/store", ".nix-profile", ".asdf", ".volta",
+ ".rustup", ".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",
@@ -266,9 +266,12 @@ 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 folder is nvm and every Node it installed; only its download
- // cache is one.
- let onlyThisPart = [".cocoapods/repos": ".cocoapods/repos/trunk", ".nvm": ".nvm/.cache"]
+ // 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.
+ let onlyThisPart = [
+ ".cocoapods/repos": ".cocoapods/repos/trunk", ".nvm": ".nvm/.cache", ".pyenv": ".pyenv/cache",
+ ".rbenv": ".rbenv/cache",
+ ]
for definition in DeveloperCaches.definitions {
for path in definition.folders.map(\.path) {
for pattern in forbidden {
@@ -686,6 +689,23 @@ struct DeveloperCachesTests {
#expect(locations.first?.isRecommended == true)
}
+ @Test func offersThePackagesPyenvAndRbenvKeptAndNeverTheirInstalledVersions() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file(".pyenv/cache/Python-3.13.1.tar.xz", bytes: 400_000)
+ try directory.file(".pyenv/versions/3.13.1/bin/python3", bytes: 400_000)
+ try directory.file(".rbenv/cache/ruby-3.4.1.tar.gz", bytes: 400_000)
+ try directory.file(".rbenv/versions/3.4.1/bin/ruby", bytes: 400_000)
+ let tools = DeveloperCaches.definitions.filter { ["pyenv", "rbenv"].contains($0.id) }
+
+ let locations = await DeveloperCaches.scan(tools, homeDirectory: directory.url).flatMap(\.locations)
+
+ let home = directory.url.path(percentEncoded: false)
+ #expect(Set(locations.map { String($0.url.path(percentEncoded: false).dropFirst(home.count)) }) == [
+ ".pyenv/cache", ".rbenv/cache",
+ ])
+ #expect(locations.allSatisfy { $0.kind == .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 {