Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions internal/workspace/localInstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (ws *Workspace) uninstall(pkg string, logWriter io.Writer, indent string) e
outputBuff := &bytes.Buffer{}

var cmd *exec.Cmd
var notMountedOutput string
var notMounted func(output, pkgSrc string) bool

hasFusermount, err := commandExists("fusermount")
if err != nil {
Expand All @@ -197,19 +197,20 @@ func (ws *Workspace) uninstall(pkg string, logWriter io.Writer, indent string) e
if hasFusermount {
// Use fusermount if that exists
cmd = exec.Command("fusermount", "-u", pkgSrc)
notMountedOutput = fmt.Sprintf("fusermount: entry for %s not found", pkgSrc)
notMounted = fusermountNotMounted
} else {
// Otherwise fallback to umount
cmd = exec.Command("umount", pkgSrc)
notMountedOutput = fmt.Sprintf("umount: %s: not mounted", pkgSrc)
notMounted = umountNotMounted
}

cmd.Stderr = io.MultiWriter(stderrBuff, outputBuff)
cmd.Stdout = outputBuff

err = cmd.Run()

if err != nil {
if !strings.HasPrefix(stderrBuff.String(), notMountedOutput) {
if !notMounted(stderrBuff.String(), pkgSrc) {
// We don't care if the write to stderr failed
_, _ = io.Copy(os.Stderr, outputBuff)

Expand Down Expand Up @@ -274,6 +275,14 @@ func (ws *Workspace) uninstall(pkg string, logWriter io.Writer, indent string) e
return nil
}

func umountNotMounted(output, pkgSrc string) bool {
return strings.HasPrefix(output, fmt.Sprintf("umount: %s: not currently mounted", pkgSrc)) || strings.HasPrefix(output, fmt.Sprintf("umount: %s: not mounted", pkgSrc))
}

func fusermountNotMounted(output, pkgSrc string) bool {
return strings.HasPrefix(output, fmt.Sprintf("fusermount: entry for %s not found", pkgSrc))
}

func (ws *Workspace) ClearSrc() error {
settings, err := ws.Settings()
if err != nil {
Expand Down