Skip to content

bug: asdf plugin test does not cleanup the test plugin #2130

Open

Description

@elijahr

Describe the Bug

When I am actively developing my plugin and running asdf plugin test nim ., I have to manually run asdf plugin remove asdf-test-nim before each run.

I could see it being sometimes useful to keep the installed test plugin around if a plugin developer needs to inspect the installation, but that should be opt-in rather than opt-out. The default behavior should be to uninstall the plugin once the test is done, whether it succeeds or fails.

Steps to Reproduce

# From some plugin directory
asdf plugin test nim .
asdf plugin test nim .  # Fails because `asdf-test-nim` is already installed

Expected Behaviour

# From some plugin directory
asdf plugin test nim .
asdf plugin test nim .  # Works beause `asdf-test-nim` was uninstalled

Actual Behaviour

FAILED: nim was not properly installed reason: Plugin named asdf-test-nim already added

Environment

macos and linux

asdf plugins affected (if relevant)

asdf-nim

Activity

  1. gunzy83 commented on Oct 9, 2025

    @gunzy83

    Looks like it is not cleaning up after a failure:

    	// Install plugin
    	err = plugins.Add(conf, testName, url, ref)
    	if err != nil {
    		failTest(l, fmt.Sprintf("%s was not properly installed reason: %s", name, err))
    	}
    
    	// Remove plugin
    	var blackhole strings.Builder
    	defer plugins.Remove(conf, testName, &blackhole, &blackhole)

    There are other places it can fail further down the function (eg installing one version) which results in the same behaviour where the defer does not run.

  2. CAOShurong commented on Aug 12, 2026

    @CAOShurong
    Contributor

    I reproduced this on current master (f87a31efc67c041af49f0d3c566840e4f30a12cb) with an isolated ASDF_DATA_DIR and a local test plugin missing its install callback. The first run exits 1 and leaves plugins/asdf-test-dummy; the second run then fails because that test plugin is already added. I'm working on a small change that returns failures through the CLI action so the existing deferred cleanup runs, plus a Bats regression covering failure cleanup and a repeat run.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions