Git_hooks - failure of tasks with specified environment variables

Hello,

I’d like to run some tasks with env variables specified (MIX_ENV=test), but with current configuration it fails whenever I set this variable.

mix.exs:
image

config.exs:

mix git_hooks.run pre_commit:
image

Maybe someone has to face with similar problem?

Thanks!

Can you show the full error of mix ecto.reset? Preferably with text and not screenshots, too.

1 Like

That’s all I see after running mix git_hooks.run pre_commit. This is whole error message.
mix ecto.reset or MIX_ENV=test mix ecto.reset works absolutely fine. The problem is to set test env in hook.

This is confusing. Your OP shows that the reset command has failed?

Excuse me, could you expand the abbreviation “OP”?

Your original post.

Yes, it fails when I run it as git hook with env: [“MIX_ENV”, “test”]. Without this option it works fine. It doesn’t matter if it’s ecto.reset or any other command. Every task with environment variable fail.

Some examples:
mix ecto.reset - works
MIX_ENV=test mix ecto.reset - works
mix git_hooks.run pre_commit without specified env - works
mix git_hooks.run pre_commit with env option - fail

I see. But can’t you provide more details of the error? Surely when you run the task in the terminal there’s something more than “execution failed”?

That is an exact output:

jan-swiatek@MacBook-Air-Jan discuss % mix git_hooks.run pre_commit
:arrow_upper_right: Running hooks for :pre_commit
Resolving Hex dependencies…
Dependency resolution completed:
Unchanged:
artificery 0.4.3
bamboo 1.7.1
bamboo_smtp 2.0.0
blankable 1.0.0
browser 0.4.4
bunt 0.2.0
certifi 2.8.0
combine 0.10.0
connection 1.1.0
cors_plug 2.0.3
cowboy 2.9.0
cowboy_telemetry 0.3.1
cowlib 2.11.0
credo 1.6.1
db_connection 2.4.2
decimal 2.0.0
dialyxir 1.0.0
distillery 2.1.1
doctor 0.19.0
earmark 1.3.6
ecto 3.7.2
ecto_sql 3.7.2
edeliver 1.8.0
erlex 0.2.6
ex_aws 2.2.9
ex_aws_s3 2.3.2
ex_machina 2.7.0
file_system 0.2.10
floki 0.32.0
gen_smtp 0.14.0
gettext 0.19.0
git_hooks 0.7.3
hackney 1.18.0
html_entities 0.5.2
httpoison 1.8.0
idna 6.1.1
jason 1.3.0
joken 2.1.0
jose 1.11.2
meck 0.9.2
metrics 1.0.1
mime 1.6.0
mimerl 1.2.0
mix_audit 0.1.4
mock 0.3.7
parse_trans 3.3.1
phoenix 1.5.13
phoenix_ecto 4.4.0
phoenix_html 2.14.3
phoenix_live_reload 1.3.3
phoenix_live_view 0.15.7
phoenix_mtm 1.0.0
phoenix_pubsub 2.0.0
plug 1.13.6
plug_cowboy 2.5.2
plug_crypto 1.2.2
poison 3.1.0
postgrex 0.16.3
pow 1.0.26
ranch 1.8.0
recase 0.7.0
sentry 8.0.6
slugger 0.3.0
sobelow 0.11.1
ssl_verify_fun 1.1.6
sweet_xml 0.7.2
telemetry 0.4.3
timex 3.6.4
tzdata 1.0.5
unicode_util_compat 0.7.0
uuid 1.1.8
waffle 1.1.6
waffle_ecto 0.0.11
web_push_encryption 0.2.3
yamerl 0.10.0
yaml_elixir 2.4.0
All dependencies are up to date
:heavy_check_mark: mix deps.get was successful
:heavy_check_mark: mix format --dry-run --check-formatted was successful
No retired packages found
:heavy_check_mark: mix hex.audit was successful
No vulnerabilities found.
:heavy_check_mark: mix deps.audit was successful
Generated discuss app
:heavy_check_mark: mix compile was successful
× pre_commit: mix ecto.reset execution failed
jan-swiatek@MacBook-Air-Jan discuss %

Then it seems that the code that runs those tasks is cutting the output. Why don’t you run all these one by one by yourself? Then the first one that fails should have more error details available in the terminal.

Because without that I’m not sure that we can help you.

There is no more output. Every single task run by myself in terminal just works. It fails only in one case - when I use git_hooks with env option. I sent all output provided. I have not more information about this failure.

Then I am afraid you’ll have to delve into the source of git_hooks.

Oh, it was my mistake. I just realized that I wrote env: ["MIX_ENV", "test"] instead of env: [{"MIX_ENV", "test"}].

2 Likes