From df6a791dba19d96981d0a1f7afb149e48833f734 Mon Sep 17 00:00:00 2001 From: Michel Blanc Date: Sun, 24 Apr 2022 15:56:38 +0200 Subject: [PATCH] fixes uninstall --- SYSTEM.md | 13 +++++++++++++ cmd/root.go | 13 ------------- internal/app/app.go | 8 +------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/SYSTEM.md b/SYSTEM.md index 5904917..ed0b649 100644 --- a/SYSTEM.md +++ b/SYSTEM.md @@ -28,6 +28,9 @@ To run in global mode, you can either install from [scratch](#installation), or Note that operations that mutate state (i.e. `install`, `uninstall`, `update`, `upgrade`) will have to be executed as `root`. +Note that it is recommended to set `BINENV_GLOBAL=true` if you intend to +use mostly system-wide mode (see [Caveat](#caveat)). + ## Installation Note: instructions for BSD systems have not been tested. @@ -123,6 +126,16 @@ binenv -g install binenv - adjust path in your rcfiles according to your preferences +## Caveat + +To use system-wide installed binaries, you have to set the `BINENV_GLOBAL=true` +environment variable. + +This is required since binenv shim will look in default, user-related paths if +this is not set. + +## FAQ + ### Why do I have to use `-g` ? Can't binenv autodetect global mode ? Yes it could. But what if you want to use a user installation along a global diff --git a/cmd/root.go b/cmd/root.go index 2b3dbd4..4ae8e4b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -100,19 +100,6 @@ selected.`, return rootCmd } -func truthify(s string) bool { - s = strings.ToLower(s) - // trueness suggestions courtesy of Github co-pilot - return s == "true" || s == "1" || s == "yes" || s == "y" || s == "on" || s == "enable" || s == "enabled" || s == "active" -} - -// func envOrDefault(k, def string) string { -// if v := os.Getenv(k); v != "" { -// return v -// } -// return def -// } - func initializeConfig(cmd *cobra.Command) error { v := viper.New() diff --git a/internal/app/app.go b/internal/app/app.go index 8d74151..64b5536 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -510,7 +510,7 @@ func (a *App) uninstall(dist, version string) error { } } - lnk := filepath.Join(a.bindir, dist) + lnk := filepath.Join(a.linkdir, dist) if err = os.Remove(lnk); err != nil { return err } @@ -827,12 +827,6 @@ func (a *App) CreateShimFor(dist string) error { func (a *App) Execute(args []string) { dist := filepath.Base(args[0]) - a.logger.Debug(). - Str("bindir", a.bindir). - Str("cachedir", a.cachedir). - Str("configdir", a.configdir). - Msg("directory settings") - // Check if args[0] is managed by us. If not write an error and exit. This // should not happen since, if we are here, we must have used a symlink to // the shim.