fix(mix/scm): handle GIT_TRACE=1#15019
Merged
Merged
Conversation
When GIT_TRACE=1 is set in the env, `mix deps.get` fails with an
unexpected `FunctionClauseError` due to `git --version`'s output
including trace output from git itself:
```
λ GIT_TRACE=1 mix deps.get
* Getting ariel (git@github.com:foo/bar.git - main)
22:17:06.786357 git.c:476 trace: built-in: git init --quiet
22:17:06.798692 git.c:476 trace: built-in: git remote add origin git@github.com:foo/bar.git
22:17:06.804333 git.c:476 trace: built-in: git config remote.origin.url git@github.com:foo/bar.git
** (FunctionClauseError) no function clause matching in Mix.SCM.Git.parse_version/1
The following arguments were given to Mix.SCM.Git.parse_version/1:
# 1
"22:17:06.809548 git.c:476 trace: built-in: git version\ngit version 2.50.1\n"
Attempted function clauses (showing 1 out of 1):
defp parse_version(<<"git version ", version::binary>>)
(mix 1.18.4) lib/mix/scm/git.ex:426: Mix.SCM.Git.parse_version/1
(mix 1.18.4) lib/mix/scm/git.ex:419: Mix.SCM.Git.git_version/0
(mix 1.18.4) lib/mix/scm/git.ex:132: Mix.SCM.Git.checkout/2
(elixir 1.18.4) lib/file.ex:1665: File.cd!/2
(mix 1.18.4) lib/mix/dep/fetcher.ex:68: Mix.Dep.Fetcher.do_fetch/3
(mix 1.18.4) lib/mix/dep/converger.ex:238: Mix.Dep.Converger.all/9
(mix 1.18.4) lib/mix/dep/converger.ex:170: Mix.Dep.Converger.init_all/8
(mix 1.18.4) lib/mix/dep/converger.ex:110: Mix.Dep.Converger.all/4
```
This patch updates `git_version` to handle trace noise by running
parse on the final output line of `git --version`.
New `deps.git_test` added to exercise the `GIT_TRACE` condition.
Member
|
Instead of parsing it, perhaps we should force GIT_TRACE=0? |
|
A bit off-topic, but I've had this same command fail for me, but for a different reason. The terminal printed something before the git version. The main issue for me was that the error was very obscure and it took me a while to find why this was failing. I've searched if there was a better way to find the git version, but apparently there isn't 🙁 so I just fixed my terminal output in the end. |
josevalim
reviewed
Dec 17, 2025
Member
|
@tcoopman I see, so we should make this more robust in general. Sounds good. |
Member
|
💚 💙 💜 💛 ❤️ |
Contributor
Author
|
thank you, @josevalim |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When GIT_TRACE=1 is set in the env,
mix deps.getfails with an unexpectedFunctionClauseErrordue togit --version's output including trace output from git itself:This patch updates
git_versionto handle trace noise by running parse on the final output line ofgit --version.New
deps.git_testadded to exercise theGIT_TRACEcondition.