pkgx icon indicating copy to clipboard operation
pkgx copied to clipboard

Force magic to reload the file `.tea.yaml` on git hook `post-checkout`

Open 4brunu opened this issue 2 years ago • 6 comments

Hi,

I want to force magic to reload the .tea.yaml on the git hook post-checkout, to ensure the I'm using the correct version of each tool mentioned in the .tea.yaml.

Doing cd . in the terminal works, but not on the Makefile, nor on a script file.

Is there any way to force maging to reload the .tea.yaml?

Thanks

4brunu avatar Jul 31 '23 15:07 4brunu

source <(tea -E) or equivalent for your shell, I think the best way with bash is eval "$(tea -E)"

mxcl avatar Jul 31 '23 15:07 mxcl

nice trick too, we should document this.

oh actually the magic actually executes: source <(tea +tea.xyz/magic -Esk --chaste env) if you want to be completely correct. This adds the TEA_REWIND env to ensure the env can be undone.

-k for keep going so it doesn't fail in directories that have no env, --chaste to prevent it downloading packages, -s for silent.

I'm in the process of standardzing this weird-ass command to something more normal.

mxcl avatar Jul 31 '23 15:07 mxcl

Hi, thanks for the quick answer. I'm using zsh on macOS.

source <(tea +tea.xyz/magic -Esk --chaste env) works on the terminal, but fails on the Makefile with the following error:

source <(tea +tea.xyz/magic -Esk --chaste env)
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `source <(tea +tea.xyz/magic -Esk --chaste env)'

source <(tea -E) has the same error on the Makefile.

eval "$(tea -E)" has no effect on the Makefile.

4brunu avatar Jul 31 '23 15:07 4brunu

I also tried to run eval "$(tea +tea.xyz/magic -Esk --chaste env)" or bash -c "source <(tea +tea.xyz/magic -Esk --chaste env)" from the Makefile, to it has no effect.

4brunu avatar Aug 01 '23 07:08 4brunu

/bin/sh is bash v3 on macOS which cannot handle that syntax. You can use eval "$(tea stuff)" instead.

v1 has changed things, dev will work in the terminal, but not in a Makefile. This should be fixed, and we will do so. In the meantime for a Makefile you can use tea as a runner eg. tea [email protected]. Not ideal in that you have to repeat version info, but it'll work for now.

edit: apologies for the late response, I've been preparing tea 1.0 release for weeks!

mxcl avatar Sep 11 '23 17:09 mxcl

Hey, thanks for the response and for the work on tea 1.0.

Can we keep this issue open, while tea/magic doesn't support this use case in the Makefile?

4brunu avatar Sep 11 '23 17:09 4brunu