Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support aqua rm for go_install packages without --all #2905

Closed
sapphi-red opened this issue May 18, 2024 · 4 comments · Fixed by #3101
Closed

Support aqua rm for go_install packages without --all #2905

sapphi-red opened this issue May 18, 2024 · 4 comments · Fixed by #3101
Labels
enhancement New feature or request
Milestone

Comments

@sapphi-red
Copy link
Contributor

Feature Overview

aqua rm doesn't support go_install packages unless --all is passed.
https://aquaproj.github.io/docs/guides/uninstall-packages/#limitation

It would be nice if aqua rm supports removing go_install packages without requiring --all.

Why is the feature needed?

When I try some packages that is go_install type and decided not to use it, I want to remove the binaries to save storage space.

Workaround

  • manually finding the binary and removing it
    • aqua rm is easier
  • run aqua rm --all
    • I'll have to install packages again

Example Code

No response

Note

refs https://github.com/orgs/aquaproj/discussions/2903
refs #538

@sapphi-red sapphi-red added the enhancement New feature or request label May 18, 2024
@suzuki-shunsuke
Copy link
Member

📝

func (c *Controller) removePackage(logE *logrus.Entry, rootDir string, pkg *registry.PackageInfo) error {
path := pkg.PkgPath()
if path == "" {
logE.WithField("package_type", pkg.Type).Warn("this package type can't be removed")
return nil
}

func (p *PackageInfo) PkgPath() string {
switch p.Type {
case PkgInfoTypeGitHubArchive, PkgInfoTypeGoBuild, PkgInfoTypeGitHubContent, PkgInfoTypeGitHubRelease:
return filepath.Join(p.Type, "github.com", p.RepoOwner, p.RepoName)
case PkgInfoTypeCargo:
return filepath.Join(p.Type, "crates.io", p.Crate)
case PkgInfoTypeGoInstall, PkgInfoTypeHTTP:
return ""
}
return ""
}

case PkgInfoTypeGoInstall:
p, err := p.RenderPath()
if err != nil {
return "", fmt.Errorf("render Go Module Path: %w", err)
}
return filepath.Join(rootDir, "pkgs", pkgInfo.Type, p, pkg.Version, "bin"), nil

@suzuki-shunsuke
Copy link
Member

I remembered why we didn't support this feature.

go_install's path can depend on a version.

e.g.

https://aquaproj.github.io/docs/reference/registry-config/go-install-package

path: github.com/volatiletech/sqlboiler/v{{(semver .Version).Major}}

To uninstall a package, aqua must be able to detect a file path to be removed independent of version.

In the above example, it's github.com/volatiletech/sqlboiler but it's difficult to detect the path programatically.

To resolve this issue, my idea is to add a field to detect a file path to be removed.

# TODO: decide the field name
# package_dir, base_dir
removed_dir: github.com/volatiletech/sqlboiler

Using this field, we can uninstall not only go_install type packages but also http type packages.

@suzuki-shunsuke
Copy link
Member

@suzuki-shunsuke suzuki-shunsuke added this to the v2.33.0 milestone Sep 21, 2024
@suzuki-shunsuke
Copy link
Member

v2.33.0 is out 🎉
https://github.com/aquaproj/aqua/releases/tag/v2.33.0

This release supports not only go_install but also http packages.
Furthermore, we could resolve this issue without adding a new field.

#2905 (comment)

To resolve this issue, my idea is to add a field to detect a file path to be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants