Cog-Creators / Red-DiscordBot

A multi-function Discord bot
https://docs.discord.red
GNU General Public License v3.0
4.73k stars 2.3k forks source link

[V3 CogManager] removepath breaks when changing OS #2609

Closed ZeLarpMaster closed 3 years ago

ZeLarpMaster commented 5 years ago

Command bugs

TL;DR: Answer to this is yes, because, when removing it, this causes this to not find the path.

Command name

[p]removepath

What cog is this command from?

CogManagerUI

What were you expecting to happen?

The specified path to be removed

What actually happened?

[23/04/2019 21:40] ERROR events on_command_error 207: Exception in command 'removepath'
Traceback (most recent call last):
  File "<my path to red>/RedBotV3/.venv/lib/python3.6/site-packages/discord/ext/commands/core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "<my path to red>/RedBotV3/.venv/lib/python3.6/site-packages/redbot/core/cog_manager.py", line 372, in removepath
    await ctx.bot.cog_mgr.remove_path(to_remove)
  File "<my path to red>/RedBotV3/.venv/lib/python3.6/site-packages/redbot/core/cog_manager.py", line 182, in remove_path
    paths.remove(path)
ValueError: list.remove(x): x not in list

How can we reproduce this issue?

  1. Launch bot on Windows
  2. Run [p]addpath <valid Windows path>
  3. Stop bot
  4. Launch bot on Ubuntu
  5. Run [p]paths
  6. Run [p]removepath with the number of the Windows path
ZeLarpMaster commented 5 years ago

A simple fix I'd see is removing the .resolve() in remove_path.

The path literally comes from a pop of the list at the given index, so I don't see why we'd need to resolve it again. If remove_path is called from elsewhere, it should be giving a valid path already (and otherwise will receive an exception).