Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"You're not inside a cpython repo right now! πŸ™…" says cherry_picker when I'm in my cpython git repo #99

Open
gpshead opened this issue Nov 4, 2023 · 17 comments Β· May be fixed by #112 or #119

Comments

@gpshead
Copy link
Member

gpshead commented Nov 4, 2023

python/cpython/gpshead (main)$ cherry_picker a6c1c04d4d2339f0094422974ae3f26f8c7c8565 3.12 --upstream-remote=upstream --pr-remote=origin
🐍 πŸ’ ⛏
You're not inside a cpython repo right now! πŸ™…
python/cpython/gpshead (main)$ cherry_picker --version
cherry_picker, version 2.2.0

It appears that some validation logic was added that doesn't take actual git clone configurations into account.

That logic appears to have been there "forever" (5 years per Blame) but there was a recent change a month-ish ago to the b471da1 that added a get_state_and_verify() call to check_repo(). Related?

The other issue aside from the bug is that the error message is inaccurate and thus unhelpful - It does not provide full details on exactly what it thinks is amiss in the state is detected vs exactly what state expects so I can't tell anything about the nature of the bug or if there's something simple I could do given I am within a git clone of cpython with many remote repos and branches that I've been using for years.

Getting overly creative with pdb, the error message that was suppressed was apparently:

ValueError: Run state cherry-picker.state=BACKPORT_LOOP_START in Git config is not known.
Perhaps it has been set by a newer version of cherry-picker. Try upgrading.
Valid states are: BACKPORT_PAUSED, UNSET. If this looks suspicious, raise an issue at https://github.com/python/cherry-picker/issues/new.
As the last resort you can reset the runtime state stored in Git config using the following command: `git config --local --remove-section cherry-picker`
@hugovk
Copy link
Member

hugovk commented Nov 4, 2023

Are you using Git worktrees? Maybe it doesn't know how to checkout branches already checked out in other directories.

If so, does it work when you cd to the 3.12 worktree dir first?

@gpshead
Copy link
Member Author

gpshead commented Nov 4, 2023

See the swallowed ValueError at the bottom. it was leftover cherry-picker state from some earlier forcably abandoned run due to whatever other things i was hitting.

@dpr-0
Copy link

dpr-0 commented Nov 16, 2023

I use version 2.2.0 cherry_picker and git version 2.39.3 (Apple Git-145). After I run cherry_picker --continue fail, than I saw You're not inside a cpython repo right now! πŸ™…
Here is my error message.

Β» cherry_picker --continue
🐍 πŸ’ ⛏
Traceback (most recent call last):
  File "/opt/homebrew/bin/cherry_picker", line 8, in <module>
    sys.exit(cherry_pick_cli())
             ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/cherry_picker/cherry_picker.py", line 802, in cherry_pick_cli
    cherry_picker.continue_cherry_pick()
  File "/opt/homebrew/lib/python3.11/site-packages/cherry_picker/cherry_picker.py", line 591, in continue_cherry_pick
    commits = get_commits_from_backport_branch(base)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/cherry_picker/cherry_picker.py", line 902, in get_commits_from_backport_branch
    output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'log', '--format=%H', '3.11..']' returned non-zero exit status 128.

@skirpichev
Copy link
Member

@dpr-0, try to look to the .git/config: probably it has some remnants of cherry-picker.state (like BACKPORT_LOOP_START above). Removing related section from that file was a solution for me.

@dpr-0
Copy link

dpr-0 commented Nov 16, 2023

@dpr-0, try to look to the .git/config: probably it has some remnants of cherry-picker.state (like BACKPORT_LOOP_START above). Removing related section from that file was a solution for me.

I have removed it and re-run cherry_picker but I still get subprocess.CalledProcessError like above.

@aloisklink
Copy link
Contributor

subprocess.CalledProcessError: Command '['git', 'log', '--format=%H', '3.11..']' returned non-zero exit status 128.

I had a similar error, since the 3.11 branch did not exist in my local repo. I had to first create the branch with git switch 3.11 (which then printed a message like Branch '3.11' set up to track remote branch '3.11' from 'origin'.

@hugovk
Copy link
Member

hugovk commented Jan 28, 2024

I suggest we remove the "You're not inside a cpython repo right now! πŸ™…" handling and let the original exception and message bubble up and be displayed.

@belm0
Copy link

belm0 commented Feb 12, 2024

I had a similar error, since the 3.11 branch did not exist in my local repo. I had to first create the branch with git switch 3.11 (which then printed a message like Branch '3.11' set up to track remote branch '3.11' from 'origin'.

This worked for me. Shouldn't cherry_picker take care of checking out the release branch?

@steverep
Copy link

I got this error and now I cannot get it to go away. Tried adding the remote tracking branches which didn't help. Tried completely removing the backport branch and starting over, still get the error. 😞

@belm0
Copy link

belm0 commented Feb 13, 2024

I got this error and now I cannot get it to go away. Tried adding the remote tracking branches which didn't help. Tried completely removing the backport branch and starting over, still get the error. 😞

remove cherry-picker state in .git/config

@jaraco
Copy link
Member

jaraco commented Mar 13, 2024

I ran into this issue today also. I'd run cherry_picker, then resolved a conflict, then mistakenly committed the change. From there, I tried to --continue, but got an error, then tried to clean things up by deleting the branch, but got stuck on the "not inside a cpython repo" error.

 cpython main @ git-id
3f54d1cfe7
 cpython main @ cherry_picker a2548077614f81f25a2c3465dabb7a0a3885c40c 3.11
🐍 πŸ’ ⛏
You're not inside a cpython repo right now! πŸ™…

I was able to bypass the error by manually cleaning up the .git/config.

@jaraco
Copy link
Member

jaraco commented Mar 13, 2024

I had a similar error, since the 3.11 branch did not exist in my local repo. I had to first create the branch with git switch 3.11 (which then printed a message like Branch '3.11' set up to track remote branch '3.11' from 'origin'.

This worked for me. Shouldn't cherry_picker take care of checking out the release branch?

I ran into this issue also, but the workaround didn't work for me. I was in the middle of a cherry pick, so couldn't switch to 3.11. I couldn't --abort because of the "not inside" error.

@serhiy-storchaka
Copy link
Member

I ran into this issue just now.

#119 at least provides more info:

🐍 πŸ’ ⛏
You're not inside a cpython repo right now! πŸ™…
Run state cherry-picker.state=CONTINUATION_STARTED in Git config is not known.
Perhaps it has been set by a newer version of cherry-picker. Try upgrading.
Valid states are: BACKPORT_PAUSED, UNSET. If this looks suspicious, raise an issue at https://github.com/python/cherry-picker/issues/new.
As the last resort you can reset the runtime state stored in Git config using the following command: `git config --local --remove-section cherry-picker`

@pitrou
Copy link
Member

pitrou commented Mar 17, 2024

remove cherry-picker state in .git/config

This worked for me to suppress the error, but this workaround should be mentioned somewhere in the error message.

@ncoghlan
Copy link
Contributor

ncoghlan commented Jun 2, 2024

Just ran into this the exact same way that @jaraco did: resolving a conflict and committing the result.

It's really easy to do when using VSCode, since the conflict resolution UI in there just naturally leads into committing when you've resolved everything.

@xyb
Copy link

xyb commented Jun 13, 2024

I ran into this issue also. I'm working on my forked cpython repo, but I faced same error message even I'm already added upstream as a remote. Thanks @aloisklink the git switch 3.13 trick saved me. I think cherry-picker should switch to the target branch automatically if it doesn't exist in this situation.

@tomasr8
Copy link
Member

tomasr8 commented Nov 12, 2024

I just ran into the same thing with cherry picker 2.3.0. I can confirm that the solutions to remove cherry picker-related config from .git/config and checking out the branch helped, but it'd be nice if cherry picker could handle this automatically πŸ™‚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet