Devcontainers do not work with git worktree

Open
#350 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
git, python

Research direction

Reproduce the issue with git worktree add ../blueapi-enum add-enum-for-endpoint, then open the worktree in its devcontainer and run uv sync. Inspect the devcontainer configuration and worktree .git handling; done means Git commands and uv sync work from the opened worktree without the reported repository or setuptools-scm errors.

Written by the indexing model from the issue text.

Description

Way to replicate this issue

  1. In a cloned repository add a worktree by
git worktree add ../blueapi-enum add-enum-for-endpoint

You will see that inside the worktree the .git has a link to the parent and not the

gitdir: /scratch/ckk43848/blueapi/.git/worktrees/blueapi-enum
  1. Open the blueapi-enum in devcontainer
    See the following issues
fatal: not a git repository: /scratch/ckk43848/blueapi/.git/worktrees/blueapi-enum

uv sync issue

root ➜ /workspaces/blueapi-enum 
$ uv sync
Resolved 274 packages in 0.90ms
  × Failed to build `blueapi @ file:///workspaces/blueapi-enum`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `setuptools.build_meta.build_editable` failed (exit status: 1)

      [stderr]
      Traceback (most recent call last):
        File "<string>", line 14, in <module>
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/setuptools/build_meta.py", line 481, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
          self.run_setup()
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/setuptools/build_meta.py", line 317, in run_setup
          exec(code, locals())
        File "<string>", line 1, in <module>
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/setuptools/__init__.py", line 117, in setup
          return distutils.core.setup(**attrs)  # type: ignore[return-value]
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 148, in setup
          _setup_distribution = dist = klass(attrs)
                                       ^^^^^^^^^^^^
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/setuptools/dist.py", line 321, in __init__
          _Distribution.__init__(self, dist_attrs)
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 307, in __init__
          self.finalize_options()
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/setuptools/dist.py", line 790, in finalize_options
          ep(self)
        File "/root/.local/share/uv/python/cpython-3.11.15-linux-x86_64-gnu/lib/python3.11/contextlib.py", line 81, in inner
          return func(*args, **kwds)
                 ^^^^^^^^^^^^^^^^^^^
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/setuptools_scm/_integration/setuptools.py", line 203, in infer_version
          _infer_version_impl(
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/setuptools_scm/_integration/setuptools.py", line 236, in _infer_version_impl
          result.apply(dist)
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/setuptools_scm/_integration/version_inference.py", line 183, in apply
          data = infer_version_with_config(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/setuptools_scm/_integration/version_inference.py", line 123, in
      infer_version_with_config
          _version_missing(config, tool=env.tool_names[0])
        File "/cache/uv/builds-v0/.tmprWugKC/lib/python3.11/site-packages/vcs_versioning/_get_version_impl.py", line 263, in _version_missing
          raise LookupError(error_msg)
      LookupError: setuptools-scm was unable to detect version for /workspaces/blueapi-enum.

      Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout
      without the .git folder) don't contain the necessary metadata and will not work.

      For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj

      Alternatively, set the version with the environment variable SETUPTOOLS_SCM_PRETEND_VERSION_FOR_${NORMALIZED_DIST_NAME} as described in
      https://setuptools-scm.readthedocs.io/en/latest/config/


hint: Build failures usually indicate a problem with the package or the build environmen

Possible solution:

Try to mount the parent as well when devcontainer knows that it is a worktree

Dominant language
Jinja
Stars
28
Forks
10
Avg merge
3d 4h
Merged PRs (30d)
4

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DiamondLightSource/python-copier-template

All issues in DiamondLightSource/python-copier-template

Similar issues

More DevTools issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.