question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

shallow_since appears to be broken

See original GitHub issue

Description of the problem / feature request:

shallow_since appears to be broken.

Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Try to build //:BUILD.boost from https://github.com/nelhage/rules_boost/commit/df908358c605a7d5b8bbacde07afbaede5ac12cf. You’ll receive a recommendation for shallow_since. Insert that recommendation, and suddenly Bazel fails to find that commit at all.

What operating system are you running Bazel on?

Windows

What’s the output of bazel info release?

release 1.1.0

What’s the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

N/A

Have you found anything relevant by searching the web?

No

Any other information, logs, or outputs that you want to share?

Create an empty BUILD.bazel alongside the following WORKSPACE:

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(name="rules_boost", commit="df908358c605a7d5b8bbacde07afbaede5ac12cf", remote="https://github.com/nelhage/rules_boost")

Now run bazel --ignore_all_rc_files query "deps(@rules_boost//:BUILD.boost)":

bazel --ignore_all_rc_files query "deps(@rules_boost//:BUILD.boost)"
@bazel --ignore_all_rc_files clean --expunge

It outputs something like the following (after formatting/redactions):

INFO: Writing tracer profile to 'command.profile.gz'
DEBUG: Rule 'rules_boost' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1569511515 +0200"
DEBUG: Call stack for the definition of repository 'rules_boost' which is a git_repository (rule definition at external/bazel_tools/tools/build_defs/repo/git.bzl:195:18):
 - WORKSPACE:2:1
ERROR: no such target '@rules_boost//:BUILD.boost': target 'BUILD.boost' not declared in package ''; however, a source file of this name exists.  (Perhaps add 'exports_files(["BUILD.boost"])' to /BUILD?) defined by external/rules_boost/BUILD
Loading: 1 packages loaded

Now add shallow_since="1569511515 +0200" as recommended and re-run the query:

INFO: Writing tracer profile to 'command.profile.gz'
INFO: Call stack for the definition of repository 'rules_boost' which is a git_repository (rule definition at external/bazel_tools/tools/build_defs/repo/git.bzl:195:18):
 - WORKSPACE:2:1
ERROR: An error occurred during the fetch of repository 'rules_boost':
error running 'git reset --hard df908358c605a7d5b8bbacde07afbaede5ac12cf' while working with @rules_boost:
fatal: Could not parse object 'df908358c605a7d5b8bbacde07afbaede5ac12cf'.
ERROR: no such package '@rules_boost//'
Loading: 0 packages loaded

Suddenly Bazel seems to be unable to find the commit altogether.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
nelhagecommented, Aug 25, 2020

I did some digging here, and reported an upstream bug to git

The upshot is that --shallow-since is subtly incorrect when the provided timestamp would cause us to include some parents of a merge, but not others. In the case provided here, nelhage/rules_boost@df90835 has a commit timestamp of 1569511515. That commit is the second part of a merge, nelhage/rules_boost@76f3064; that merge’s first parent is nelhage/rules_boost@a83197e, with an older commit timestamp of 1569487118

The bug I reported results in git discarding all parents of the merge (nelhage/rules_boost@76f3064), including the desired commit.

For now, the workaround for bazel users – where available – is to switch your commit= line to point to a commit on the first-parent spine, e.g. nelhage/rules_boost@76f3064. If you add the suggested shallow_since line for that commit, things work fine.

For Bazel itself, it might be nice to recognize this situation and adjust the shallow_since recommendation, at least until the upstream bug can be sorted out. I’m not certain offhand what the right/easiest heuristic to detect it is, though.

2reactions
asuffieldcommented, Mar 2, 2021

It turns out that the workaround proposed here doesn’t work either.

The shallow_since bug is even worse than I expected. It stops at the first commit which has any parents before the cutoff time. This means we have the following horrible scenario:

  1. Latest commit on main branch is aaaa, with parents baaa and bbbb. aaaa is at 8am, baaa is at 6am and bbbb is at 4am
  2. I create a git_repository rule with commit = “aaaa”, shallow_since = “4am”
  3. This works fine when I build it
  4. Somebody adds a new commit caaa to main branch, with parents aaaa and cbbb. caaa is at 9am, cbbb is at 2am
  5. git clone --shallow_since=4am will now fetch only caaa because it has a parent before 4am, and aaaa will not be fetched

This is completely unusable and I don’t see a workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git cannot create shallow-since locally - Stack Overflow
It seems to wok consistently when I get a shallow repo using depth=1 so thanks for that. That being said I'm experience some...
Read more >
git-clone Documentation - Git
If you want to break the dependency of a repository cloned with --shared on its source ... This option is incompatible with --depth...
Read more >
African violets: Restoring or Restarting - Violet Barn
About 2 inches of bare stem appears between soil level and the lowest row of leaves. African violets should be repotted every 6...
Read more >
Opioid Overdose - StatPearls - NCBI Bookshelf
Once in the body, opiates are broken down by the liver to inactive compounds that are ... After ingestion, systemic symptoms appear rapidly, ......
Read more >
Brew 2.0.1 Release - GitClear
Request parameter cookie key setting broken · #5670 · Typecast 'id' attribute in read_attribute when ... Fix context menu not showing correctly in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found