Skip to content

Commit 5598f26

Browse files
authored
add helpful env vars during shell + run (#1548)
## Summary Adds a few helpful Env Vars to the shell/run/services environment. These should help in situations where a developer needs to refer to files within their project directory, but doesn't want to hardcode the path into their configuration Since this just adds a few variables to the shell environment, it should be a fairly low risk change ## How was it tested? Locally
1 parent d2b5be5 commit 5598f26

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/impl/devbox.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ func (d *Devbox) computeNixEnv(ctx context.Context, usePrintDevEnvCache bool) (m
766766
// Append variables from current env if --pure is not passed
767767
currentEnv := os.Environ()
768768
env, err := d.parseEnvAndExcludeSpecialCases(currentEnv)
769+
769770
if err != nil {
770771
return nil, err
771772
}
@@ -869,6 +870,11 @@ func (d *Devbox) computeNixEnv(ctx context.Context, usePrintDevEnvCache bool) (m
869870
return nil, err
870871
}
871872

873+
// Add helpful env vars for a Devbox project
874+
env["DEVBOX_PROJECT_ROOT"] = d.projectDir
875+
env["DEVBOX_CONFIG_DIR"] = d.projectDir + "/devbox.d"
876+
env["DEVBOX_PACKAGES_DIR"] = d.projectDir + "/.devbox/virtenv/.wrappers"
877+
872878
// Include env variables in devbox.json
873879
configEnv, err := d.configEnvs(ctx, env)
874880
if err != nil {

0 commit comments

Comments
 (0)