Cannot install plugin. Error: Expected status 200, got 400

Hi,
This is kind of a follow-up to my pb in Installing local plugin to a remote instance without relying on npm - #8 par GregRc, figured a new thread was better :slight_smile:
Although I managed to install the simplelogo plugin from its git repository, I’m blocked since days trying to install other plugins like the quickstart with no success. Sometimes i could install simplelogo back, sometimes i couldn’t with same errors shown. So I tried to restart from the beginning by following @JohnLivingston tutorial at Plugin Peertube From Scratch - Vidéos Globenet but again I’m stuck at the first plugin install, with same errors below:

error[01/03/2023 15:01:14] Cannot install plugin /peertube-plugin-test, removing it...
{
  "err": {
    "err": {
      "stack": "Error: Command failed: yarn add file:/peertube-plugin-test\nwarning package.json: No license field\nwarning No license field\nerror Package \"peertube-plugin-quickstart\" refers to a non-existing file '\"/plugins/updatevideo\"'.\n\n    at ChildProcess.exithandler (node:child_process:402:12)\n    at ChildProcess.emit (node:events:513:28)\n    at maybeClose (node:internal/child_process:1100:16)\n    at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)",
      "message": "Command failed: yarn add file:/peertube-plugin-test\nwarning package.json: No license field\nwarning No license field\nerror Package \"peertube-plugin-quickstart\" refers to a non-existing file '\"/plugins/updatevideo\"'.\n",
      "code": 1,
      "killed": false,
      "signal": null,
      "cmd": "yarn add file:/peertube-plugin-test"
    },
    "stdout": "yarn add v1.22.19\n[1/4] Resolving packages...\ninfo Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.\n",
    "stderr": "warning package.json: No license field\nwarning No license field\nerror Package \"peertube-plugin-quickstart\" refers to a non-existing file '\"/plugins/updatevideo\"'.\n"
  }
}
warn[01/03/2023 15:01:14] Cannot unregister plugin undefined.
{
  "err": {
    "stack": "Error: Unknown plugin undefined to unregister\n    at PluginManager.<anonymous> (/app/dist/server/lib/plugins/plugin-manager.js:185:23)\n    at Generator.next (<anonymous>)\n    at /app/node_modules/tslib/tslib.js:118:75\n    at new Promise (<anonymous>)\n    at Object.__awaiter (/app/node_modules/tslib/tslib.js:114:16)\n    at PluginManager.unregister (/app/dist/server/lib/plugins/plugin-manager.js:181:24)\n    at PluginManager.<anonymous> (/app/dist/server/lib/plugins/plugin-manager.js:266:28)\n    at Generator.next (<anonymous>)\n    at /app/node_modules/tslib/tslib.js:118:75\n    at new Promise (<anonymous>)\n    at Object.__awaiter (/app/node_modules/tslib/tslib.js:114:16)\n    at PluginManager.uninstall (/app/dist/server/lib/plugins/plugin-manager.js:263:24)\n    at PluginManager.<anonymous> (/app/dist/server/lib/plugins/plugin-manager.js:233:32)\n    at Generator.throw (<anonymous>)\n    at rejected (/app/node_modules/tslib/tslib.js:116:69)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)",
    "message": "Unknown plugin undefined to unregister"
  }
}
error[01/03/2023 15:01:14] Cannot uninstall plugin /peertube-plugin-test after failed installation.
{
  "err": {
    "stack": "TypeError: Cannot read properties of undefined (reading 'replace')\n    at Function.normalizePluginName (/app/dist/server/models/server/plugin.js:147:24)\n    at Function.loadByNpmName (/app/dist/server/models/server/plugin.js:21:27)\n    at PluginManager.<anonymous> (/app/dist/server/lib/plugins/plugin-manager.js:271:55)\n    at Generator.throw (<anonymous>)\n    at rejected (/app/node_modules/tslib/tslib.js:116:69)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)",
    "message": "Cannot read properties of undefined (reading 'replace')"
  }
}
error[01/03/2023 15:01:14] Cannot remove plugin /peertube-plugin-test after failed installation.
{
  "err": {
    "stack": "Error: Invalid NPM plugin name to install\n    at checkNpmPluginNameOrThrow (/app/dist/server/lib/plugins/yarn.js:63:15)\n    at /app/dist/server/lib/plugins/yarn.js:34:9\n    at Generator.next (<anonymous>)\n    at /app/node_modules/tslib/tslib.js:118:75\n    at new Promise (<anonymous>)\n    at Object.__awaiter (/app/node_modules/tslib/tslib.js:114:16)\n    at removeNpmPlugin (/app/dist/server/lib/plugins/yarn.js:33:20)\n    at PluginManager.<anonymous> (/app/dist/server/lib/plugins/plugin-manager.js:238:58)\n    at Generator.throw (<anonymous>)\n    at rejected (/app/node_modules/tslib/tslib.js:116:69)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)",
    "message": "Invalid NPM plugin name to install"
  }
}
warn[01/03/2023 15:01:14] Cannot install plugin /peertube-plugin-test.
{
  "err": {
    "err": {
      "stack": "Error: Command failed: yarn add file:/peertube-plugin-test\nwarning package.json: No license field\nwarning No license field\nerror Package \"peertube-plugin-quickstart\" refers to a non-existing file '\"/plugins/updatevideo\"'.\n\n    at ChildProcess.exithandler (node:child_process:402:12)\n    at ChildProcess.emit (node:events:513:28)\n    at maybeClose (node:internal/child_process:1100:16)\n    at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)",
      "message": "Command failed: yarn add file:/peertube-plugin-test\nwarning package.json: No license field\nwarning No license field\nerror Package \"peertube-plugin-quickstart\" refers to a non-existing file '\"/plugins/updatevideo\"'.\n",
      "code": 1,
      "killed": false,
      "signal": null,
      "cmd": "yarn add file:/peertube-plugin-test"
    },
    "stdout": "yarn add v1.22.19\n[1/4] Resolving packages...\ninfo Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.\n",
    "stderr": "warning package.json: No license field\nwarning No license field\nerror Package \"peertube-plugin-quickstart\" refers to a non-existing file '\"/plugins/updatevideo\"'.\n"
  }
}

What’s strange there is references to "peertube-plugin-quickstart\ and /plugins/updatevideo\ which were local plugins I tried to install. Looks like any plugin installation will block because of those. I probably stacked several mistakes as I’m new to Peertube. First, as suggested in the other thread, I added this line to peertube/volumes my docker-compose:
- ~/sources/peertube-plugins/:/plugins:ro
so that I could have, thru a /plugins folder in my docker cli, access to my debian plugin files in ~/sources/peertube-plugins/. I thought that this way each plugin I’m working on would be a subfolder of ~/sources/peertube-plugins/ in debian. It worked nicely with the peertube-plugin-simplelogo subfolder as i could install this plugin. But any other folder would fail. Moreover, my UpdateVideo plugin folder was ~/sources/peertube-plugins/updatevideo instead of ~/sources/peertube-plugins/peertube-plugin-updatevideo and I wonder if this hasn’t made things worse. I tried renaming it with no success, no matter how much cache deleted or docker containers remounted. Logs always showed references to those paths. Plus, those folders have been deleted, so I don’t see why their names appear here. Looks like obsolete data stored somewhere.

I also tried modifying peertube/volumes in docker-compose.yml so that each plugin has its own alias, like:
~/sources/peertube-plugins/peertube-plugin-test/:/peertube-plugin-test:ro
which is not a desired solution as I don’t want to change this file for every new plugin, but anyway again, same errors.

So any help here would be greatly welcome :pray:

That was the first problem. It is perhaps not enough documented, but your plugins must be in a folder with name beginning with peertube-plugin-. (and same for themes, where the name should begin with peertube-theme).

Then, check your package.json: have you renamed the plugin? from peertube-plugin-quickstart to peertube-plugin-updatevideo? The name must be the same as the folder name.

Maybe the error is due to previous installation. Try to check this file on your server: data/plugins/package.json (replace data with the complete path to your peertube storage dir).
Perhaps this file contains old plugin names. It should look like this:

{
  "dependencies": {
    "peertube-plugin-livechat": "file:/peertube-plugin-livechat"
  }
}

If there are previous plugin references (something like "updatevideo:": "file://peertube-plugins/updatevideo"), just try to delete them.

2 « J'aime »

Thanks John, it was indeed that package.json which kept erroneous data because of wrong paths. I can now install and uninstall several plugins and watch that package.json update nicely, now going back to your tut, and thank you for that too! :smiling_face:

1 « J'aime »

Great!

The technical explanation (if it can help some people to understand what happened):

  • to install plugin, peertube adds them in this /var/www/peertube/storage/plugins/package.json (if you are on docker, it will be /data/plugins/packages.json if I remember well), then calls yarn install to install all packages that are referenced, and their dependencies
  • to differenciate plugins and themes, Peertube use the directory name: if it starts with peertube-plugin- it is a plugin, if peertube-theme-, it is a theme
2 « J'aime »

Do you mean the package.json in data/plugins/ folder? Because in peertube/storage all I can see is logs and tmp folders. But my local instance runs with Docker so files may be elsewhere, i.e. that package.json path is in fact ~/sources/peertube/support/docker/production/docker-volume/data/plugins/package.json

/var/www/peertube/storage/ is the path for a standard installation. For a docker one, this is mapped to /data/. I will edit my previous message.

2 « J'aime »