Skip to content

Does pkgm uninstall remove the symlinks as well? #73

Open

Description

@sanchitram1

I am trying to figure out the dev integration with pkgm. The start of my trouble was when I had a pkgx.yaml file with python@3.8 specified as a dependency, but dev was using python@3.13 from ~/.pkgx/....

Found on dev that the recommended way to use dev for isolated environments is to use pkgm. So, I installed python@3.8 via:

pkgm install python@3.8

I noticed I was getting this error:

❯ pkgm install python@3.8
× nothing provides: q!
│ we haven’t pkgd this yet. can you?
╰─➤ https://docs.pkgx.sh/pantry

I got past that error only if I removed the pkgx.yaml file – once I did that and tried to re-run, I got this error:

error: Uncaught (in promise) AlreadyExists: File exists (os error 17): symlink '/Users/sanch/.local/pkgs/libpng.org/v1.6.40/lib/libpng.la' -> '/Users/sanch/.local/lib/libpng.la'
  Deno.symlinkSync(src, dst);
       ^
    at Object.symlinkSync (ext:deno_fs/30_fs.js:504:3)
    at symlink_with_overwrite (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:501:8)
    at processEntry (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:419:7)
    at eventLoopTick (ext:core/01_core.js:178:7)
    at async processEntry (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:412:9)
    at async symlink (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:397:7)
    at async install (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:159:7)
    at async file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:65:20

ok, so there's already a libpng.la in ~/.local. So, i tried uninstalling (and sudo uninstalling, to remove it from /usr/bin/local, in case it was there too). pasting a big log chunk here - but the idea is that I have libpng.org, i uninstall it and it goes away, i install python@3.8 and it throws an error, and then libpng.org has magically reappeared.

~/L/Mo/com~apple~CloudDocs/Documents/berkeley/fall 2025 ·············· 12:32:36
❯ pkgm list
/usr/local/pkgs/tcl-lang.org/v8.6.13
/usr/local/pkgs/sqlite.org/v3.44.2
/usr/local/pkgs/bytereef.org/mpdecimal/v2.5.1
/usr/local/pkgs/sourceware.org/libffi/v3.4.4
/usr/local/pkgs/sourceware.org/bzip2/v1.0.8
/usr/local/pkgs/openssl.org/v1.1.1w
/usr/local/pkgs/tukaani.org/xz/v5.4.5
/usr/local/pkgs/freetype.org/v2.13.2
/usr/local/pkgs/pkgx.sh/v2.7.0
/usr/local/pkgs/pkgx.sh/v1.5.0
/usr/local/pkgs/zlib.net/v1.3.0
/usr/local/pkgs/gnu.org/readline/v8.2.0
/usr/local/pkgs/invisible-island.net/ncurses/v6.4.0
/usr/local/pkgs/libexpat.github.io/v2.5.0
/usr/local/pkgs/pip.pypa.io/v23.3.2
/usr/local/pkgs/curl.se/ca-certs/v2023.12.12
/usr/local/pkgs/x.org/x11/v1.8.11
/usr/local/pkgs/x.org/protocol/v2023.2.0
/usr/local/pkgs/x.org/xau/v1.0.11
/usr/local/pkgs/x.org/xdmcp/v1.1.4
/usr/local/pkgs/x.org/exts/v1.3.5
~/.local/pkgs/libpng.org/v1.6.40
~/.local/pkgs/tcl-lang.org/v8.6.13
~/.local/pkgs/sqlite.org/v3.44.2
~/.local/pkgs/bytereef.org/mpdecimal/v2.5.1
~/.local/pkgs/sourceware.org/libffi/v3.4.4
~/.local/pkgs/sourceware.org/bzip2/v1.0.8
~/.local/pkgs/freedesktop.org/pkg-config/v0.29.2
~/.local/pkgs/github.com/spencerkimball/stargazers/v0.0.0
~/.local/pkgs/openssl.org/v1.1.1w
~/.local/pkgs/tukaani.org/xz/v5.4.5
~/.local/pkgs/freetype.org/v2.13.2
~/.local/pkgs/pkgx.sh/v2.7.0
~/.local/pkgs/pkgx.sh/v1.5.0
~/.local/pkgs/pkgx.sh/dev/v1.5.0
~/.local/pkgs/zlib.net/v1.3.0
~/.local/pkgs/gnu.org/readline/v8.2.0
~/.local/pkgs/invisible-island.net/ncurses/v6.4.0
~/.local/pkgs/libexpat.github.io/v2.5.0
~/.local/pkgs/pip.pypa.io/v23.3.2
~/.local/pkgs/curl.se/ca-certs/v2023.12.12
~/.local/pkgs/x.org/x11/v1.8.11
~/.local/pkgs/x.org/protocol/v2023.2.0
~/.local/pkgs/x.org/util-macros/v1.20.0
~/.local/pkgs/x.org/xau/v1.0.11
~/.local/pkgs/x.org/xdmcp/v1.1.4
~/.local/pkgs/x.org/exts/v1.3.5
~/.local/pkgs/x.org/xcb/v1.16.0

~/L/Mo/com~apple~CloudDocs/Documents/berkeley/fall 2025 ·············· 12:33:46
❯ pkgm uninstall libpng.org
uninstalling ~/.local/pkgs/libpng.org

~/L/Mo/com~apple~CloudDocs/Documents/berkeley/fall 2025 ·············· 12:34:00
❯ pkgm install python@3.8
error: Uncaught (in promise) AlreadyExists: File exists (os error 17): symlink '/Users/sanch/.local/pkgs/libpng.org/v1.6.40/lib/libpng.la' -> '/Users/sanch/.local/lib/libpng.la'
  Deno.symlinkSync(src, dst);
       ^
    at Object.symlinkSync (ext:deno_fs/30_fs.js:504:3)
    at symlink_with_overwrite (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:501:8)
    at processEntry (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:419:7)
    at eventLoopTick (ext:core/01_core.js:178:7)
    at async processEntry (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:412:9)
    at async symlink (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:397:7)
    at async install (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:159:7)
    at async file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:65:20

~/L/Mo/com~apple~CloudDocs/Documents/berkeley/fall 2025 ··········· 8s 12:34:13
❯ pkgm list
/usr/local/pkgs/tcl-lang.org/v8.6.13
/usr/local/pkgs/sqlite.org/v3.44.2
/usr/local/pkgs/bytereef.org/mpdecimal/v2.5.1
/usr/local/pkgs/sourceware.org/libffi/v3.4.4
/usr/local/pkgs/sourceware.org/bzip2/v1.0.8
/usr/local/pkgs/openssl.org/v1.1.1w
/usr/local/pkgs/tukaani.org/xz/v5.4.5
/usr/local/pkgs/freetype.org/v2.13.2
/usr/local/pkgs/pkgx.sh/v2.7.0
/usr/local/pkgs/pkgx.sh/v1.5.0
/usr/local/pkgs/zlib.net/v1.3.0
/usr/local/pkgs/gnu.org/readline/v8.2.0
/usr/local/pkgs/invisible-island.net/ncurses/v6.4.0
/usr/local/pkgs/libexpat.github.io/v2.5.0
/usr/local/pkgs/pip.pypa.io/v23.3.2
/usr/local/pkgs/curl.se/ca-certs/v2023.12.12
/usr/local/pkgs/x.org/x11/v1.8.11
/usr/local/pkgs/x.org/protocol/v2023.2.0
/usr/local/pkgs/x.org/xau/v1.0.11
/usr/local/pkgs/x.org/xdmcp/v1.1.4
/usr/local/pkgs/x.org/exts/v1.3.5
~/.local/pkgs/libpng.org/v1.6.40
~/.local/pkgs/tcl-lang.org/v8.6.13
~/.local/pkgs/sqlite.org/v3.44.2
~/.local/pkgs/bytereef.org/mpdecimal/v2.5.1
~/.local/pkgs/sourceware.org/libffi/v3.4.4
~/.local/pkgs/sourceware.org/bzip2/v1.0.8
~/.local/pkgs/freedesktop.org/pkg-config/v0.29.2
~/.local/pkgs/github.com/spencerkimball/stargazers/v0.0.0
~/.local/pkgs/openssl.org/v1.1.1w
~/.local/pkgs/tukaani.org/xz/v5.4.5
~/.local/pkgs/freetype.org/v2.13.2
~/.local/pkgs/pkgx.sh/v2.7.0
~/.local/pkgs/pkgx.sh/v1.5.0
~/.local/pkgs/pkgx.sh/dev/v1.5.0
~/.local/pkgs/zlib.net/v1.3.0
~/.local/pkgs/gnu.org/readline/v8.2.0
~/.local/pkgs/invisible-island.net/ncurses/v6.4.0
~/.local/pkgs/libexpat.github.io/v2.5.0
~/.local/pkgs/pip.pypa.io/v23.3.2
~/.local/pkgs/curl.se/ca-certs/v2023.12.12
~/.local/pkgs/x.org/x11/v1.8.11
~/.local/pkgs/x.org/protocol/v2023.2.0
~/.local/pkgs/x.org/util-macros/v1.20.0
~/.local/pkgs/x.org/xau/v1.0.11
~/.local/pkgs/x.org/xdmcp/v1.1.4
~/.local/pkgs/x.org/exts/v1.3.5
~/.local/pkgs/x.org/xcb/v1.16.0

Activity

  1. sanchitram1 commented on Oct 31, 2025

    @sanchitram1
    Author

    my question is what's happening in the uninstall process? am I missing an additional thing that I gotta remove?

  2. jhheider commented on Oct 31, 2025

    @jhheider
    Contributor

    looking at

    pkgm/pkgm.ts

    Lines 540 to 620 in e3934de

    async function uninstall(arg: string) {
    let found: { project: string } | undefined =
    (await hooks.usePantry().find(arg))?.[0];
    if (!found) {
    found = await plumbing.which(arg);
    }
    if (!found) {
    console.error(`no such pkg: ${arg}`);
    return false;
    }
    const set = new Set<string>();
    const files: Path[] = [];
    let dirs: Path[] = [];
    const pkg_dirs: Path[] = [];
    const root = install_prefix();
    const dir = root.join("pkgs", found.project);
    if (!dir.isDirectory()) {
    console.error(`not installed: ${dir}`);
    if (
    root.string == "/usr/local" &&
    Path.home().join(".local/pkgs", found.project).isDirectory()
    ) {
    console.error(
    `%c! rerun without \`sudo\` to uninstall ~/.local/pkgs/${found.project}`,
    "color:yellow",
    );
    } else if (new Path("/usr/local/pkgs").join(found.project).isDirectory()) {
    console.error(
    `%c! rerun as \`sudo\` to uninstall /usr/local/pkgs/${found.project}`,
    "color:yellow",
    );
    }
    return false;
    }
    console.error("%cuninstalling", "color:red", dir);
    pkg_dirs.push(dir);
    for await (const [pkgdir, { isDirectory }] of dir.ls()) {
    if (!isDirectory) continue;
    for await (const { path, isDirectory } of walk(pkgdir.string)) {
    const leaf = new Path(path).relative({ to: pkgdir });
    const resolved_path = root.join(leaf);
    if (set.has(resolved_path.string)) continue;
    if (!resolved_path.exists()) continue;
    if (isDirectory) {
    dirs.push(resolved_path);
    } else {
    files.push(resolved_path);
    }
    }
    }
    // we need to delete this in a heirachical fashion or they don’t delete
    dirs = dirs.sort().reverse();
    if (files.length == 0) {
    console.error("unexpectedly not installed");
    Deno.exit(1);
    }
    for (const path of files) {
    if (!path.isDirectory()) {
    Deno.removeSync(path.string);
    }
    }
    for (const path of dirs) {
    if (path.isDirectory()) {
    try {
    Deno.removeSync(path.string);
    } catch {
    // some dirs will not be removable
    }
    }
    }
    for (const path of pkg_dirs) {
    Deno.removeSync(path.string, { recursive: true });
    }
    return true;
    }
    it looks possible the symlinks aren't being cleaned up... maybe? Hence, when it tries to symlink in the new copy, it's erroring. Try this:

    pkgx uninstall libpng.org
    ls -l /Users/sanch/.local/pkgs/libpng.org/v1.6.40/lib/libpng.la
    ls -l /Users/sanch/.local/lib/libpng.la

    we would hope both of those would be gone on uninstall. you mentioned sudo, so it's just possible you've got a root-owned inode that you can't fix as user.

  3. sanchitram1 commented on Oct 31, 2025

    @sanchitram1
    Author

    looks like the symlink does exist!

    ~/Library/Mobile Documents/com~apple~CloudDocs/Documents/berkeley/fall 2025 ························· 12:48:01
    ❯ sudo pkgm uninstall libpng.org
    uninstalling /usr/local/pkgs/libpng.org
    
    ~/Library/Mobile Documents/com~apple~CloudDocs/Documents/berkeley/fall 2025 ························· 12:48:05
    ❯ ls -l /Users/sanch/.local/pkgs/libpng.org/v1.6.40/lib/libpng.la
    ls: /Users/sanch/.local/pkgs/libpng.org/v1.6.40/lib/libpng.la: No such file or directory
    
    ~/Library/Mobile Documents/com~apple~CloudDocs/Documents/berkeley/fall 2025 ························· 12:48:16
    ❯ ls -l /Users/sanch/.local/lib/libpng.la                        
    lrwxr-xr-x  1 sanch  staff  57 Oct 31 12:19 /Users/sanch/.local/lib/libpng.la -> /Users/sanch/.local/pkgs/libpng.org/v1.6.40/lib/libpng.la
    
  4. jhheider commented on Oct 31, 2025

    @jhheider
    Contributor

    sounds like a pkgm uninstall bug. does removing the symlink get you working?

  5. sanchitram1 commented on Oct 31, 2025

    @sanchitram1
    Author

    it's the symlinks – I ran into the next symlink problem:

    error: Uncaught (in promise) AlreadyExists: File exists (os error 17): symlink '/usr/local/pkgs/pip.pypa.io/v23.3.2/bin/pip3' -> '/usr/local/bin/pip3'
      Deno.symlinkSync(src, dst);
           ^
        at Object.symlinkSync (ext:deno_fs/30_fs.js:504:3)
        at symlink_with_overwrite (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:501:8)
        at processEntry (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:419:7)
        at eventLoopTick (ext:core/01_core.js:178:7)
        at async processEntry (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:412:9)
        at async symlink (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:397:7)
        at async install (file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:159:7)
        at async file:///Users/sanch/.pkgx/pkgx.sh/pkgm/v0.11.1/bin/pkgm:65:20
    

    i'll go ahead and remove all the symlinks and see if it works out

  6. sanchitram1 commented on Oct 31, 2025

    @sanchitram1
    Author
    ~/Library/Mobile Documents/com~apple~CloudDocs/Documents/berkeley/fall 2025 ························· 12:54:05
    ❯ sudo pkgm uninstall pip.pypa.io   
    uninstalling /usr/local/pkgs/pip.pypa.io
    unexpectedly not installed
    

    hmm…? that's a fun turn of phrase . looks like pip is refusing to uninstall for some reason. should I try to manually delete and see what happens then?

  7. jhheider commented on Oct 31, 2025

    @jhheider
    Contributor

    yep. sounds like uninstall needs work, and perhaps install needs to give the option to be a bit more aggressive about clobbering things.

  8. mxcl commented on Nov 4, 2025

    @mxcl
    Contributor

    You need to upgrade pkgx, you probs haven’t done that in a while. I thought we included a version check in pkgm but I guess not.

    -q! is a new(ish) pkgx flag

  9. sanchitram1 commented on Nov 4, 2025

    @sanchitram1
    Author

    looks like i've got the latest of all:

    ❯ pkgm --version
    pkgm 0.11.1
    
    ~ ·········································································································· 14:20:43
    ❯ pkgx --version
    pkgx 2.7.0
    
    ~ ·········································································································· 14:21:12
    ❯ dev --version
    dev 1.5.0
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions