Skip to content

Evaluate environment variables in the local plugin path #2639

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 1 commit into from
Jul 1, 2025

Conversation

adamjreed
Copy link
Contributor

Summary

Fixes #2638

See issue for description of the problem. This PR is just a one-line change to evaluate current environment variables as devbox assembles the path for local plugins. This will allow things like a dynamic root directory for plugin source.

How was it tested?

Built devbox locally with code change and copied it to /usr/local/bin/devbox. Refreshed global environment and plugins defined with an environment variable in the path now resolve properly.

Community Contribution License

All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.

By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.

@Lagoja Lagoja requested review from mikeland73 and Copilot and removed request for mikeland73 July 1, 2025 19:08
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables evaluation of environment variables in the local plugin path, allowing dynamic root directories for plugin sources.

  • Uses os.ExpandEnv to expand environment variables in LocalPlugin.Path()
  • No other functional changes
Comments suppressed due to low confidence (2)

internal/plugin/local.go:58

  • Add unit tests for LocalPlugin.Path() to verify that environment variables in ref.Path are correctly expanded.
	path := os.ExpandEnv(l.ref.Path)

internal/plugin/local.go:57

  • [nitpick] Update or add a doc comment for Path() to indicate that it now expands environment variables in the provided path.
func (l *LocalPlugin) Path() string {

@Lagoja
Copy link
Contributor

Lagoja commented Jul 1, 2025

Looks pretty straightforward to me. @mikeland73 any pitfalls you see with this?

Copy link
Contributor

@mikeland73 mikeland73 left a comment

Choose a reason for hiding this comment

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

LGTM

@mikeland73
Copy link
Contributor

This is good. Only caveat is that environment variables defined in devbox.json or passed via -e won't be available. That's probably OK?

Another approach could be to do the expansion before determining plugin type (i.e. local, remote, etc). That way we could do something like:

"includes": "${GOPLUGIN:-github:jetify-com/devbox-plugins?dir=go-monorepo}"

which would make it nicer to develop remote plugins (currently at Jetify we use this go plugin in a private repo and it's a bit annoying to test plugin updates)

Anyway let's not let perfect be enemy of good, will merge this. We can improve in follow ups.

@mikeland73 mikeland73 merged commit 70964d8 into jetify-com:main Jul 1, 2025
29 checks passed
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.

Evaluate environment variables in local plugin path
3 participants