conda-smithy: v1 recipe fails when using `git` as `source` on Windows

When using this recipe with the c-f infrastructure:

context:
  name: katago
  version: 1.15.3

package:
  name: ${{ name|lower }}
  version: ${{ version }}

source:
  git: https://github.com/lightvector/KataGo.git
  tag: v${{ version }}

build:
  number: 0
  script:
    - touch hello.txt

about:
  summary: GTP engine and self-play learning in Go
  license: MIT
  license_file: LICENSE
  homepage: https://github.com/lightvector/KataGo

extra:
  recipe-maintainers:
    - hadim

It fails during a window build with:

 ╭─ Running build for recipe: katago-1.15.3-h57928b3_0
 │
 │ ╭─ Fetching source code
 │ │ Fetching source from git repo: https://github.com/lightvector/KataGo.git
 │ │ Fetching repository from https://github.com/lightvector/KataGo.git at refs/tags/v1.15.3 into D:\bld\src_cache\KataGo.git
 │ │ × error Command failed: `git rev-parse "refs/tags/v1.15.3"`
 │ │
 │ ╰─────────────────── (took 8 seconds)
 │
 ╰─────────────────── (took 8 seconds)
Error: 
  × Failed to run git command: failed to get valid hash for rev

Traceback (most recent call last):
  File "D:\a\1\s\.ci_support\build_all.py", line 356, in <module>
    build_all(os.path.join(root_dir, "recipes"), args.arch)
  File "D:\a\1\s\.ci_support\build_all.py", line 192, in build_all
    build_folders_rattler_build(recipes_dir, platform, arch, channel_urls)
  File "D:\a\1\s\.ci_support\build_all.py", line 292, in build_folders_rattler_build
    subprocess.run(args + ["--variant-config", fp.name], check=True)

Note that it does not fail on osx and linux.

See this simple experiment to reproduce: https://github.com/conda-forge/staged-recipes/pull/28906


The original issue has been spotted at https://github.com/conda-forge/katago-feedstock/pull/11 where I was seeing actually two different but maybe related errors depending on the conda_install_tool used:

  • conda_install_tool: micromamba: same as above in staged-recipes
 ╭─ Running build for recipe: katago-1.15.3-h57928b3_0
 │
 │ ╭─ Fetching source code
 │ │ Fetching source from git repo: https://github.com/lightvector/KataGo.git
 │ │ Fetching repository from https://github.com/lightvector/KataGo.git at refs/tags/v1.15.3 into D:\bld\src_cache\KataGo.git
 │ │ × error Command failed: `git rev-parse "refs/tags/v1.15.3"`
 │ │
 │ ╰─────────────────── (took 8 seconds)
 │
 ╰─────────────────── (took 8 seconds)
Error: 
  × Failed to run git command: failed to get valid hash for rev

Traceback (most recent call last):
  File "D:\a\1\s\.ci_support\build_all.py", line 356, in <module>
    build_all(os.path.join(root_dir, "recipes"), args.arch)
  File "D:\a\1\s\.ci_support\build_all.py", line 192, in build_all
    build_folders_rattler_build(recipes_dir, platform, arch, channel_urls)
  File "D:\a\1\s\.ci_support\build_all.py", line 292, in build_folders_rattler_build
    subprocess.run(args + ["--variant-config", fp.name], check=True)
  • conda_install_tool: pixi:
Error: 
  × Failed to run git command: Git clone failed for source: Cloning into '/d/
  │ bld/src_cache/KataGo.git'...
  │ fatal: unable to access 'https://github.com/lightvector/KataGo.git/':
  │ error setting certificate file: /usr/ssl/certs/ca-bundle.crt

Important: this issue is likely c-f related, since it does not happen when building those same recipes on Windows’ runner in a simple GH action without any of the c-f infra setup (experiment not shown since it’s in a private repo).

For completeness and given the above comment, I also opened two tickets in the pixi and rattler-build repos but I doubt those are the culprit here:

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 32 (30 by maintainers)

Commits related to this issue

Most upvoted comments

That does indeed do the trick:

Image

I did more digging and here is a small snippet to help reproduce:

# fn git_src()
git clone --no-tags -n https://github.com/lightvector/KataGo.git
cd KataGo/

# fn fetch_repo()
git fetch --force --update-head-ok --no-tags https://github.com/lightvector/KataGo.git v1.16.0:v1.16.0
git config --local advice.detachedHead false
git reset --hard FETCH_HEAD
git checkout v1.16.0

# fn git_src()
git rev-parse v1.16.0^{commit}

Note that using a tag or a rev is the same (error get triggered).

With the latest rattler-build version (0.43.0) we have a more detailed error message:

│ │ Fetching source from git repo: https://github.com/lightvector/KataGo.git
 │ │ Fetching repository from https://github.com/lightvector/KataGo.git at refs/tags/v1.16.0 into D:\bld\src_cache\KataGo.git
 │ │ × error Command failed: "git" "rev-parse" "refs/tags/v1.16.0^{commit}"
 │ │ × error Command output: refs/tags/v1.16.0^commit
 │ │ × error Command stderr: fatal: ambiguous argument 'refs/tags/v1.16.0^commit': unknown revision or path not in the working tree.
 │ │ × error Use '--' to separate paths from revisions, like this:
 │ │ × error 'git <command> [<revision>...] -- [<file>...]'

After asking a few insights from a chatbot, it might be due to the shell used cmd.exe where the caret ^ is a special character used for escaping other special characters. Check the “Command output” from above, missing the { and } characters.

One solution could be to use git rev-parse "v1.16.0^{commit}" or git rev-parse v1.16.0^^^{commit} at least when the shell used is not UNIX-like.

That hypothesis could also explain why I don’t see the error on a vanilla GHA win-64 machine (cuz it uses bash).


This is just yet another hypothesis since I cannot reproduce the error neither test the fix without a Windows machine.

I just made the release that hopefully fixes this (0.43.1): https://github.com/conda-forge/rattler-build-feedstock/pull/164

However, according the man git-rev-parse the following <rev>^0 is a short-hand for <rev>^{commit} should work regardless of msys glob or noglob.

So I think we’ll use that instead in rattler-build 😃

Awesome, great to hear 😃

I confirm the fix as well. Thanks @wolfv !

Yup, that did it. With rattler-build v0.43.1 (https://github.com/conda-forge/rattler-build-feedstock/pull/164) Windows builds are passing now: https://github.com/conda-forge/rundec-feedstock/pull/8

Thanks so much for all the work, @wolfv and co!

if my feedstock declares it uses rattler-build, will it automatically use the latest release?

@consideRatio I think so, given that in my feedstock I’ve specified using rattler-build and pixi (as the install tool)

conda_build_tool: rattler-build
conda_install_tool: pixi

which results in the feedstock’s Pixi manifest having

[dependencies]
conda-build = ">=24.1"
conda-forge-ci-setup = "4.*"
rattler-build = "*"

We’ll find out in a bit though, as it will take about 20 minutes for the build products of https://github.com/conda-forge/rattler-build-feedstock/pull/164 to sync with the CDN and then we can retrigger our builds to check.

I’ll try in bit! Thanks @isuruf

Try setting $env:MSYS=noglob

Hmm there seems to be a difference between conda-forge (m2-git) and the other Git I have installed on my Windows system:

PS C:\Users\wolfv\Programs\rattler> & 'C:\Program Files\Git\bin\git.exe' rev-parse "main^{commit}"
f02bcd3a67e23acb23748a31f9e574a096f1f3a4


PS C:\Users\wolfv\Programs\rattler> C:\Users\wolfv\.pixi\envs\m2-git\Library\usr\bin\git.exe rev-parse "main^{commit}"
main^commit
fatal: ambiguous argument 'main^commit': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

I debugged a bit here and running git rev-parse in the CLI on Windows seems to work fine (with conda-forge git). Next thing would be to add additional error logging in rattler-build so that we can see what’s actually going on there.

Nice work investigating, reporting, and cross-referencing things well @hadim - I found my way here easily thanks to it!

I ran into this exact issue failing on git rev-parse with dask/dask-gateway’s feedstock, here is a build failure in conda-forge’s CI system: https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=1221415&view=logs&j=fe7faf59-69bb-5487-b8fd-a35a7bda3a51&t=55731638-dd49-5144-2129-5101b9dd1960.

The failure was triggered from working on this PR transitioning to rattler-build: https://github.com/conda-forge/dask-gateway-feedstock/pull/45