jimporter / mike

Manage multiple versions of your MkDocs-powered documentation via Git
BSD 3-Clause "New" or "Revised" License
534 stars 47 forks source link

Experiencing `error: [Errno 32] Broken pipe` when using mike in CircleCI #90

Closed NunchakusLei closed 2 years ago

NunchakusLei commented 2 years ago

The CircleCI config is,

build-docs:
    docker:
      - image: cimg/python:3.10 
    steps:
      - checkout  # Checkout the code as the first step. This is a dedicated CircleCI step.
      ...
      - run:
          name: Install dependencies for docs building
          command: |
            pip install mike
      - run:
          name: Set user
          command: |
            git config --global user.email "autobot@<domain>"
            git config --global user.name "Auto Bot"
      - run:
          name: Build the docs and push to libypc-docs
          command: |
            mike deploy << pipeline.git.tag >> --remote docs-remote --push
            mike set-default << pipeline.git.tag >> --remote docs-remote --push

I also try running mike deploy <a-version> in the CircleCI and trigger the same error. This error looks like triggered after mkdocs successfully build the documentation since I do see a message like INFO - Documentation built in 7.08 seconds right before the error. Do you have an idea of where I should check? Let me know if you need more info.

jimporter commented 2 years ago

That sounds like something went wrong when generating the commit in git fast-import. Unfortunately, I don't have time to dig into this much at the moment, but that might get you pointed in the right direction.

jimporter commented 2 years ago

Oh yeah, there was a similar issue a while back: #39. That might help too, but it makes me wonder. Are you passing "autobot@<domain>" literally for the email, or did you just remove the actual domain for privacy reasons? < or > in the user.email value will probably break things.

NunchakusLei commented 2 years ago

I remove the actual domain for privacy reasons.

NunchakusLei commented 2 years ago

Oh yeah, there was a similar issue a while back: #39. That might help too, but it makes me wonder. Are you passing "autobot@<domain>" literally for the email, or did you just remove the actual domain for privacy reasons? < or > in the user.email value will probably break things.

I saw this issue but I do have email filled in. I also have tried multiple emails but no lucks.

jimporter commented 2 years ago

In 614df68bfd0b2f28e7ddbaa7bd6e9601e17460b8, I added some better error reporting, as well as a --debug flag to report backtraces of exceptions (e.g. mike --debug deploy ...). Hopefully that will help narrow things down here.

liangzhu2000 commented 2 years ago

Hi @jimporter ,

I got the same problem. Running the --debug version returns the following:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/mike/git_utils.py", line 195, in _write
    return self._pipe.stdin.write(data)
BrokenPipeError: [Errno 32] Broken pipe
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/bin/mike", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.8/site-packages/mike/driver.py", line 346, in main
    return args.func(parser, args)
  File "/usr/lib/python3.8/site-packages/mike/driver.py", line 132, in deploy
    mkdocs_utils.build(config_file, args.version)
  File "/usr/lib/python3.8/contextlib.py", line 120, in __exit__
    next(self.gen)
  File "/usr/lib/python3.8/site-packages/mike/commands.py", line 86, in deploy
    commit.add_file(canonical_file)
  File "/usr/lib/python3.8/site-packages/mike/git_utils.py", line 240, in add_file
    self._write_data(file_info.data)
  File "/usr/lib/python3.8/site-packages/mike/git_utils.py", line 203, in _write_data
    self._write(data)
  File "/usr/lib/python3.8/site-packages/mike/git_utils.py", line 197, in _write
    raise GitCommitError(self._stderr.decode('utf-8'))
mike.git_utils.GitCommitError: error writing commit:
  git: 'fast-import' is not a git command. See 'git --help'.
  The most similar command is
    fast-export

The docker image that the CI job runs in is alpine v3.11 which only supports git-2.24.4-r0 according to https://pkgs.alpinelinux.org/packages?name=git&branch=v3.11&repo=main&arch=x86_64. git-2.24.4-r0 does not support fast-import unfortunately.

$ git --version
git version 2.24.4
$ git fast-import -h
git: 'fast-import' is not a git command. See 'git --help'.
The most similar command is
    fast-export

I think an upgrade of the base image will solve the problem. Thanks a lot for making the debug feature. It really helped my troubleshooting.

jimporter commented 2 years ago

Cool, I'm glad --debug helped! However, I'm pretty surprised that git 2.24.4 doesn't have fast-import. Looking at the docs, it's been around a lot longer than that (I think before 2.0). Maybe the alpine image only installs a subset of the Git tools, and that excludes fast-import somehow? I don't think it comes separately under normal cases, but maybe alpine does something special here...

jimporter commented 2 years ago

Apparently there's a separate package on Alpine for git fast-import: https://pkgs.alpinelinux.org/package/edge/main/x86/git-fast-import

liangzhu2000 commented 2 years ago

@jimporter Indeed. Thanks for shedding the light. The problem is now resolved.

jimporter commented 2 years ago

I think this is fixed then; @NunchakusLei, if you're still seeing issues on your end, feel free to comment and I'll take a look.