Failed `doom upgrade` - fatal: the requested upstream branch 'origin/melpa' does not exist
- Dominant language
- Emacs Lisp
- Stars
- 22.7k
- Forks
- 3.1k
- Avg merge
- 10h 46m
- Merged PRs (30d)
- 4
Description
### I confirm that...
- [X] I have searched the [issue tracker](https://github.com/doomemacs/doomemacs/issues), [documentation](https://docs.doomemacs.org), [FAQ](https://docs.doomemacs.org/-/faq), [Discourse](https://discourse.doomemacs.org), and [Google](https://google.com), in case this issue has already been reported/resolved.
- [X] I have read "[How to Debug Issues](https://doomemacs.org/d/how2debug)", and will use it to provide as much information about this issue as possible.
- [X] The issue can be reproduced on the **latest** available commit of Doom.
- [X] The issue can be reproduced on a stable release of Emacs, such as 27, 28, or 29. *(Unstable versions end in .50, .60, or .9x)*
### Expected behavior
To upgrade my Doom as usual
### Current behavior
When I upgrade Doom I see this error message:
**fatal: the requested upstream branch 'origin/melpa' does not exist**
```
$ doom upgrade
> Preparing to upgrade Doom Emacs and its packages...
✓ Doom is already up-to-date!
Doom is up-to-date!
- Using Emacs 29.4 @ /usr/bin/emacs
> Synchronizing "default" profile...
> Ensuring packages are installed and built...
- No packages need attention
> Updating all packages (this may take a while)...
x The package manager threw an error
x Last 16 lines of straight's error log:
$ git rev-parse --verify melpa
fatal: Needed a single revision
[Return code: 128]
$ cd /home/abm/.config/emacs/.local/straight/repos/with-editor/
$ git branch --track -- melpa origin/melpa
fatal: the requested upstream branch 'origin/melpa' does not exist
hint:
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint:
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.
hint: Disable this message with "git config advice.setUpstreamFailure false"
[Return code: 128]
! Wrote extended straight log to ~/.config/emacs/.local/state/logs/cli.doom.240819190308.934120.error
! Script was abruptly aborted, leaving Doom in an incomplete state!
- Run 'doom sync' to repair it.
```
At the end of the error log (~/.config/emacs/.local/state/logs/cli.doom.240819190308.934120.error) I discovered the cause of the problem:
command `git rev-parse --verify melpa` throws an weird error. But not so weird as we'll see later
```
$ git rev-parse --verify melpa
fatal: Needed a single revision
[Return code: 128]
$ cd /home/abm/.config/emacs/.local/straight/repos/with-editor/
$ git branch --track -- melpa origin/melpa
fatal: the requested upstream branch 'origin/melpa' does not exist
hint:
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint:
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.
hint: Disable this message with "git config advice.setUpstreamFailure false"
```
The thing is that listing remotes for the package is getting this
```
$ git fetch origin
$ git branch -r
origin/HEAD -> origin/main
origin/main
```
and the reason I cannot pull the `melpa` branch is this:
```
$ git config --get remote.origin.fetch
+refs/heads/main:refs/remotes/origin/main
```
Yayy, remote was set to fetch the `main` branch and only
I'd never be able to pull it with this configuration.
### **Solution** was to simply set to fech ANY under origin
`git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"`
I've identified this happens when checking out `melpa` branches for 2 packages:
https://github.com/magit/with-editor
https://github.com/magit/transient
I've also checked that `melpa` branch was created very recently for both packages
### Steps to reproduce
1. `doom upgrade`
### System Information
https://gist.github.com/wchmb/a6029b4b676fe0eeb8e177f4f453f981
Contributor guide
Research direction
Start with the `doom upgrade` output and the extended straight log at `~/.config/emacs/.local/state/logs/cli.doom.240819190308.934120.error`. Inspect the package handling for `with-editor` and `transient`, especially the branch and remote-fetch steps shown in the report. Done means `doom upgrade` completes without the missing `origin/melpa` error and the affected packages update successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- emacs-lisp, git
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100