Add redbot-update command for updating Red #6734

Merged
Jackenmen merged 56 commits from redbot_update into V3/develop 2026-05-14 00:14:44 +02:00
Jackenmen commented 2026-04-11 20:44:49 +02:00 (Migrated from github.com)

Description of the changes

Depends on #6711, #6704, #6710, #6705, #6709
Fixes #3103

Here's an asciicast previewing the update process (note that some parts are skipped depending on the conditions + you can skip a lot of steps with command flags):
asciicast

Notes

  1. While I did test that it works on the legacy Windows (i.e. conhost rather than Windows Terminal), this looks much better in Windows Terminal and I might in the future change some of our docs to start pointing people towards using Windows Terminal.
  2. On Windows, when using Python 3.8 or 3.9, you might find that the command may exit with RuntimeError: Event loop is closed ignored exception. This is something we work around in redbot, but I don't think it's worth complicating redbot-update to do the same. The workaround is not needed on 3.10+, so the problem will fully disappear with Red 3.6. This is cosmetic only; it does not affect the exit code.

Have the changes in this PR been tested?

Yes

How to test this?

Due to the fact that there are no releases with redbot-update in them yet, it's not possible to test some of this without additional dev configuration.
Here are env vars available for overriding:

  • _RED_UPDATE_PRETEND_VERSION - sets the version that redbot-update will assume to be the current version
  • _RED_UPDATE_PRETEND_SPECIFIER_TEMPLATE - a dependency specifier that will be passed to pip install when "updating"
  • _RED_RTD_CANONICAL_URL - base URL of the docs (https://docs.discord.red/en/stable/ by default)
  • RED_SIMPLE_API_URL, _RED_SIMPLE_API_ENDPOINT_PATH - allow to specify a different location that should be queried for available versions (by default, https://pypi.org/simple/ and Red-DiscordBot respectively)

Basic env var configuration may look like this (note that I did not include any of the export /$env:/set prefixes that are needed for these to actually be set in a shell, make sure to do that!):

_RED_UPDATE_PRETEND_VERSION='3.5.22'
_RED_UPDATE_PRETEND_SPECIFIER_TEMPLATE='Red-DiscordBot {extras} @ https://github.com/Jackenmen/Red-DiscordBot/archive/redbot_update.tar.gz'
_RED_RTD_CANONICAL_URL='https://jack1142-red-prs.readthedocs.io/en/make_changelog_easy_to_parse/'

If you want to test what happens when the current Python interpreter is incompatible or when a major update is released, you'll want to set the following to a custom Simple API endpoint:

RED_SIMPLE_API_URL='https://jackenmen.github.io/simple-api-red-testing/'
_RED_SIMPLE_API_ENDPOINT_PATH='Red-DiscordBot.json'

The above URL hosts a JSON file with an example 3.5.25 and 3.6.0 restricted to Python >= 3.10 (for demonstration purposes), which means you can test updating to a Red version requiring a different Python version from what you have (assuming you, e.g. use Python 3.8) and updating to a new major release.

You can also locally host a dir with a JSON file as described in the comment, if there are other scenarios you are interested in:
github.com/Jackenmen/Red-DiscordBot@5849354a44/redbot/core/utils/_internal_utils.py (L76-L82)

### Description of the changes Depends on #6711, #6704, #6710, #6705, #6709 Fixes #3103 Here's an asciicast previewing the update process (note that some parts are skipped depending on the conditions + you can skip a lot of steps with command flags): [![asciicast](https://asciinema.org/a/iC9iu3XOLotS5okc.svg)](https://asciinema.org/a/iC9iu3XOLotS5okc) ### Notes 1. While I did test that it works on the legacy Windows (i.e. conhost rather than Windows Terminal), this looks much better in Windows Terminal and I might in the future change some of our docs to start pointing people towards using Windows Terminal. 2. On Windows, when using Python 3.8 or 3.9, you might find that the command may exit with `RuntimeError: Event loop is closed` **ignored exception**. This is something we work around in `redbot`, but I don't think it's worth complicating `redbot-update` to do the same. The workaround is not needed on 3.10+, so the problem will fully disappear with Red 3.6. This is cosmetic only; it does not affect the exit code. ### Have the changes in this PR been tested? Yes ### How to test this? Due to the fact that there are no releases with redbot-update in them *yet*, it's not possible to test some of this without additional dev configuration. Here are env vars available for overriding: - `_RED_UPDATE_PRETEND_VERSION` - sets the version that `redbot-update` will assume to be the current version - `_RED_UPDATE_PRETEND_SPECIFIER_TEMPLATE` - a dependency specifier that will be passed to `pip install` when "updating" - This string is `.format()`-ted with `{extras}` (e.g. `[postgres]`) and `{versionspec}` (e.g. `==3.5.24`) placeholders - By default, the specifier is `Red-DiscordBot {extras} {versionspec}` - Link to method: https://github.com/Cog-Creators/Red-DiscordBot/blob/22fca3c589d0cd057f74689d368e6d8a11c56969/redbot/_update/common.py#L50-L59 - `_RED_RTD_CANONICAL_URL` - base URL of the docs (`https://docs.discord.red/en/stable/` by default) - `RED_SIMPLE_API_URL`, `_RED_SIMPLE_API_ENDPOINT_PATH` - allow to specify a different location that should be queried for available versions (by default, `https://pypi.org/simple/` and `Red-DiscordBot` respectively) Basic env var configuration may look like this (note that I did not include any of the `export `/`$env:`/`set ` prefixes that are needed for these to actually be set in a shell, make sure to do that!): ``` _RED_UPDATE_PRETEND_VERSION='3.5.22' _RED_UPDATE_PRETEND_SPECIFIER_TEMPLATE='Red-DiscordBot {extras} @ https://github.com/Jackenmen/Red-DiscordBot/archive/redbot_update.tar.gz' _RED_RTD_CANONICAL_URL='https://jack1142-red-prs.readthedocs.io/en/make_changelog_easy_to_parse/' ``` If you want to test what happens when the current Python interpreter is incompatible or when a major update is released, you'll want to set the following to a custom Simple API endpoint: ``` RED_SIMPLE_API_URL='https://jackenmen.github.io/simple-api-red-testing/' _RED_SIMPLE_API_ENDPOINT_PATH='Red-DiscordBot.json' ``` The above URL hosts a JSON file with an example `3.5.25` and `3.6.0` restricted to Python >= 3.10 (for demonstration purposes), which means you can test updating to a Red version requiring a different Python version from what you have (assuming you, e.g. use Python 3.8) *and* updating to a new major release. You can also locally host a dir with a JSON file as described in the comment, if there are other scenarios you are interested in: https://github.com/Jackenmen/Red-DiscordBot/blob/5849354a4429319270c9e674263dfe5bec82acef/redbot/core/utils/_internal_utils.py#L76-L82
palmtree5 (Migrated from github.com) reviewed 2026-05-13 23:46:45 +02:00
palmtree5 (Migrated from github.com) left a comment
No description provided.
I tested and found this to be working (on Python 3.11 for the purposes of testing this)
palmtree5 (Migrated from github.com) approved these changes 2026-05-14 00:13:29 +02:00
Sign in to join this conversation.
No reviewers
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!6734
No description provided.