-
Notifications
You must be signed in to change notification settings - Fork 181
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
[shell] source the hooks file in shellrc #890
Conversation
Current dependencies on/for this PR: This comment was auto-generated by Graphite. |
🤔 I need to:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but see comments
@@ -1 +1 @@ | |||
echo "Hello from a devbox shell hook!" | |||
/path/to/hooksfile/hooks.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -1 +1 @@ | |||
echo "Hello from a devbox shell hook!" | |||
/path/to/hooksfile/hooks.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this file this? i dont get it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it contains a (fake) path-to-the-hooks file.
I could: rename the file from hooks.sh
to path-to-hooks-file.txt
.
Not sure how else to capture the two scenarios of this hooks file being missing or not. 🤔 is it always present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, okay, we always write this. Confirmed by doing devbox init
for an empty project, DEVBOX_DEBUG=1 devbox shell
and inspecting the generated shellrc file: We source a hooks file which exists but is empty.
I will:
(a) delete this shellrc/nohook
test case
(b) expose a function for the hooksFilePath and refer to that in the testcase logic.
if err != nil { | ||
return err | ||
} | ||
|
||
env, err := d.nixEnv(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
somewhere around here, we should ensure the script files are written. see the run
impl
you can test if they're being written by deleting .devbox/gen/scripts
and then running devbox shell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on line 164: d.ensurePackagesAreInstalled
-> d.generateShellFiles
-> d.writeScriptsToFiles
9352874
to
fa9dbb7
Compare
@ipince please see last commit. I made a few changes. |
written[d.scriptPath(hooksFilename)] = struct{}{} | ||
|
||
// Write scripts to files. | ||
for name, body := range d.cfg.Shell.Scripts { | ||
err = d.writeScriptFile(name, d.scriptBody(body.String())) | ||
if err != nil { | ||
return errors.WithStack(err) | ||
} | ||
written[d.scriptFilename(name)] = struct{}{} | ||
written[d.scriptPath(name)] = struct{}{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ipince these two changes have a small logic change: the map's key was filename and is not filepath. I think this is safe.
Changes: - refactor: use d.scriptPath everywhere, and delete d.scriptFilename - remove nohook shell test case - remove `hook` files from shell test cases
fa9dbb7
to
6918c39
Compare
This reverts commit ea6fb6d.
Summary
Also, fix up the rust example
How was it tested?
ran
DEVBOX_DEBUG=1 devbox shell
and inspected the output to find the temp-dir in which the shellrc was written toRust example
and