Skip to content

Conversation

savil
Copy link
Collaborator

@savil savil commented Apr 17, 2023

Summary

@Lagoja is reporting an error of the form:

./.envrc:8: go: command not found

In our generated code we have eval $(devbox shellenv --init-hook).

The error is occuring because bash is executing the devbox shellenv --init-hook prior
to doing the eval. Any $(<bash command>) within the output of devbox shellenv
will also be eagerly evaluated (via bash command substituion) prior to the
final eval.

With the change: we add quotations around the $(devbox shellenv --init-hook) so
that the eval operation will execute the devbox shellenv --init-hook. And eval
each line in the output as it goes.

This way, a line in our init-hook like export GOROOT="(go env GOROOT)" will have access to the go
binary prior to go env GOROOT being executed (a prior line from devbox shellenv adds the
go binary to PATH).

How was it tested?

  1. removed go from my zshrc PATH.
  2. did rm .envrc and direnv revoke . to reset.
  3. devbox generate direnv and direnv allow .
  4. cd .. to exit directory and cd devbox to enter directory

BEFORE: saw error above
AFTER: no error seen

Copy link
Collaborator Author

savil commented Apr 17, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@savil savil requested review from gcurtis, ipince, LucilleH and Lagoja April 17, 2023 17:52
Copy link
Contributor

@Lagoja Lagoja left a comment

Choose a reason for hiding this comment

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

LGTM, I know there were a few versions of that line floating around, so @gcurtis and @LucilleH to verify this is the one we want?

@savil savil merged commit f9472a6 into main Apr 17, 2023
@savil savil deleted the savil/quote-envrc branch April 17, 2023 18:36
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.

4 participants