Skip to content

add helpful env vars during shell + run #1548

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
Oct 11, 2023
Merged

add helpful env vars during shell + run #1548

merged 2 commits into from
Oct 11, 2023

Conversation

Lagoja
Copy link
Contributor

@Lagoja Lagoja commented Oct 10, 2023

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

env["DEVBOX_PROJECT_ROOT"] = d.projectDir
env["DEVBOX_CONFIG_DIR"] = d.projectDir + "/devbox.d"
env["DEVBOX_PACKAGES_DIR"] = d.projectDir + "/.devbox/virtenv/.wrappers"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of concerns:

  1. We should insert this after the err != nil check below.
  2. We make a copy of the env on line 786 into originalEnv. So we likely want to add it some place after that.

My suggestion is add it before line 864 configEnv, err := d.configEnvs(ctx, env) so it can be used to derive other env-vars etc. in the devbox.json config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, updated!

@Lagoja Lagoja requested a review from savil October 10, 2023 22:05
@Lagoja Lagoja force-pushed the jl/useful-env-vars branch from 7829250 to 320fea9 Compare October 10, 2023 22:14
@mikeland73
Copy link
Contributor

One concern I have with this is that in these point to the last devbox project you shellenv'd into. It's not a deal breaker, but just a concern.

@Lagoja
Copy link
Contributor Author

Lagoja commented Oct 11, 2023

One concern I have with this is that in these point to the last devbox project you shellenv'd into. It's not a deal breaker, but just a concern.

I'm not sure I follow the concern, is there an issue that could cause? Since you can't have nested devbox shells, that should be ok?

@Lagoja Lagoja merged commit 5598f26 into main Oct 11, 2023
@Lagoja Lagoja deleted the jl/useful-env-vars branch October 11, 2023 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants