Skip to content

Commit b4014e8

Browse files
authored
[global] Turn on feature, keep command hidden (#622)
## Summary Turns feature on. Adds warning if profile/bin path is not in $PATH ## How was it tested? `devbox global add hello` <img width="1082" alt="image" src="https://user-images.githubusercontent.com/544948/218209148-a168ac25-08f3-4e9a-ae36-a98508b062e8.png">
1 parent d92cbb7 commit b4014e8

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

internal/boxcli/featureflag/home.go

Lines changed: 0 additions & 3 deletions
This file was deleted.

internal/impl/config.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
"github.com/fatih/color"
1515
"github.com/pkg/errors"
16-
"go.jetpack.io/devbox/internal/boxcli/featureflag"
1716
"go.jetpack.io/devbox/internal/boxcli/usererr"
1817
"go.jetpack.io/devbox/internal/cuecfg"
1918
"go.jetpack.io/devbox/internal/debug"
@@ -51,9 +50,6 @@ type Stage struct {
5150
var commitMismatchWarningShown = false
5251

5352
func (c *Config) Packages(w io.Writer) []string {
54-
if featureflag.Home.Disabled() {
55-
return c.RawPackages
56-
}
5753
path, err := GlobalConfigPath()
5854
if err != nil {
5955
return c.RawPackages

internal/impl/global.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/fatih/color"
1313
"github.com/pkg/errors"
1414
"github.com/samber/lo"
15+
"go.jetpack.io/devbox/internal/boxcli/usererr"
1516
"go.jetpack.io/devbox/internal/nix"
1617
"go.jetpack.io/devbox/internal/planner/plansdk"
1718
)
@@ -37,7 +38,10 @@ func (d *Devbox) AddGlobal(pkgs ...string) error {
3738
}
3839
}
3940
d.cfg.RawPackages = lo.Uniq(append(d.cfg.RawPackages, added...))
40-
return d.saveCfg()
41+
if err := d.saveCfg(); err != nil {
42+
return err
43+
}
44+
return ensureGlobalProfileInPath()
4145
}
4246

4347
func (d *Devbox) RemoveGlobal(pkgs ...string) error {
@@ -90,3 +94,18 @@ func GlobalConfigPath() (string, error) {
9094
}
9195
return filepath.Join(home, "/.config/devbox/"), nil
9296
}
97+
98+
// Checks if the global profile is in the path
99+
func ensureGlobalProfileInPath() error {
100+
profilePath, err := globalProfilePath()
101+
if err != nil {
102+
return err
103+
}
104+
binPath := filepath.Join(profilePath, "bin")
105+
if !strings.Contains(os.Getenv("PATH"), binPath) {
106+
return usererr.NewWarning(
107+
"devbox global profile is not in your PATH. Add `export PATH=$PATH:%s` to your shell config to fix this.", binPath,
108+
)
109+
}
110+
return nil
111+
}

0 commit comments

Comments
 (0)