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

[Bug report] Cannot register command for plugins that are symlinked #459

Open
1 of 2 tasks
solonovamax opened this issue Feb 2, 2021 · 3 comments
Open
1 of 2 tasks
Labels
bug Something isn't working v3

Comments

@solonovamax
Copy link

solonovamax commented Feb 2, 2021

Describe the bug

when registering a command from a folder that is not in the plugin directory (meaning, you created a symlink to an external directory), then powercord fails with this error:

An error occurred during initialization! TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
    at CommandsAPI.registerCommand (VM828 commands.js:56)
    at PowerBottom.startPlugin (VM1337 index.js:100)
    at async PowerBottom._load (VM133 Plugin.js:127)

To Reproduce

Create a symlink in your plugin dir to another dir
Make a simple plugin that registers a command.
The error will occur when the command is attempting to be registered.
(Hell, the object passed to the registerCommand method can even be null, that will still cause the error.)

Expected behavior

Powercord doesn't rely on directory hard path for command registration.
Perhaps instead it could work like this:
All the methods to register settings/commands use methods from the plugin class, and then the plugin class has a name that it registers.
That way, it uses the name property instead of the hacky error trace code that can break.
Or just use the stack trace, but then instead of matching with the plugin dir, it just replaces the plugin dir with an empty string, replaces . with /, and then trims the first /.

Desktop (please complete the following information):

  • OS: Arch Linux x86_64 5.10.11-arch1-1
  • Powercord version: Powercord v2 (556bae8) (latest)

Additional context

  • I checked if Discord and/or Powercord are up to date
  • I made sure this is not related to an external plugin or a theme (it can only be caused with an external plugin, but it is powercord that has the bug.)

Add any other context about the problem here.

Here is a link to the exact line on which it occurs.

@solonovamax solonovamax added the bug Something isn't working label Feb 2, 2021
@solonovamax solonovamax changed the title [Bug report] [Bug report] Cannot register command for plugins that are symlinked Feb 2, 2021
@cyyynthia
Copy link
Collaborator

I never truly gave attention to support for symlinked plugins, and given the current state of Powercord (maintenance, with bigger problems to worry about with Discord's roll out of forced context isolation), I don't know if this will ever be worked on, and the fix most likely will be v3 (since v3 core is very different from v2 core)

@solonovamax
Copy link
Author

Oof, that's a pain.

I like keeping my dev environments all in the same place, so I can quickly find projects in intellij. (I keep all programming projects in ~/Programming/[Language Name]/*)
And since there's no good way to set a custom plugin dir, I thought a symlink would be the best.

Alternatively, you could just add some simple way to add a dir that contains a plugin (Meaning, if the dir is /abcd/123/, then it looks for /abcd/123/index.js.), which is loaded along with the rest of the plugins.
(It doesn't have to be anything fancy, and should be devs only. So just make it a .json file somewhere, that holds a list of key:value pairings, where the key is the name and the value is the dir. It's hacky, but works. Or something like that.)

@cyyynthia cyyynthia added the v3 label Jun 4, 2021
@JoshuaVandaele
Copy link

I'd like to add that it also breaks themes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v3
Projects
None yet
Development

No branches or pull requests

3 participants