Skip to content

[wrappers] shellenv should not create bin wrappers #1082

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

Merged
merged 2 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Devbox interface {
GenerateDockerfile(force bool) error
GenerateEnvrcFile(force bool) error
Info(pkg string, markdown bool) error
Install(ctx context.Context) error
IsEnvEnabled() bool
ListScripts() []string
PrintEnv(ctx context.Context, includeHooks bool) (string, error)
Expand Down
3 changes: 1 addition & 2 deletions internal/boxcli/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ func installCmdFunc(cmd *cobra.Command, flags runCmdFlags) error {
if err != nil {
return errors.WithStack(err)
}
_, err = box.PrintEnv(cmd.Context(), false /* run init hooks */)
if err != nil {
if err = box.Install(cmd.Context()); err != nil {
return errors.WithStack(err)
}
fmt.Fprintln(cmd.ErrOrStderr(), "Finished installing packages.")
Expand Down
14 changes: 10 additions & 4 deletions internal/impl/devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,16 @@ func (d *Devbox) RunScript(cmdName string, cmdArgs []string) error {
return nix.RunScript(d.projectDir, strings.Join(cmdWithArgs, " "), env)
}

// Install ensures that all the packages in the config are installed and
// creates all wrappers, but does not run init hooks. It is used to power
// devbox install cli command.
func (d *Devbox) Install(ctx context.Context) error {
if _, err := d.PrintEnv(ctx, false /* run init hooks */); err != nil {
return err
}
return wrapnix.CreateWrappers(ctx, d)
}

func (d *Devbox) ListScripts() []string {
keys := make([]string, len(d.cfg.Scripts()))
i := 0
Expand All @@ -285,10 +295,6 @@ func (d *Devbox) PrintEnv(ctx context.Context, includeHooks bool) (string, error
return "", err
}

if err := wrapnix.CreateWrappers(ctx, d); err != nil {
return "", err
}

envStr := exportify(envs)

if includeHooks {
Expand Down