Installing local plugin to a remote instance without relying on npm

Hi,

node ./dist/server/tools/peertube.js plugins install -n peertube-plugin-videojs-xr --plugin-version 0.0.8

work but

node ./dist/server/tools/peertube.js plugins install --path /peertube-plugin-nttw6/

gives me

Cannot install plugin. Error: Expected status 200, got 400. 
The server responded this error: "Cannot install plugin /peertube-plugin-nttw6/".
You may take a closer look at the logs. To see how to do so, check out this page: https://github.com/Chocobozzz/PeerTube/blob/develop/support/doc/development/tests.md#debug-server-logs
    at /dist/shared/server-commands/requests/requests.js:136:19
    at /node_modules/supertest/lib/test.js:306:17
    at Test._assertFunction (/node_modules/supertest/lib/test.js:285:13)
    at Test.assert (/node_modules/supertest/lib/test.js:164:23)
    at localAssert (/node_modules/supertest/lib/test.js:120:14)
    at /node_modules/supertest/lib/test.js:125:7
    at Test.Request.callback (/node_modules/superagent/lib/node/index.js:928:3)
    at /node_modules/superagent/lib/node/index.js:1145:18
    at IncomingMessage.<anonymous> (/node_modules/superagent/lib/node/parsers/json.js:22:7)
    at IncomingMessage.emit (node:events:402:35)

despite being the example plugin. I’m wondering if it’s possible to do so or if it’s limited to a local test instance (maybe due to copying files, hence the full path requirement).

PS: remote instance is up and running, cf https://videolab.benetou.fr

To clarify, my goal here is to provide a discovery environment for people wanting to discover plugin development for PeerTube. I thought I’d provide a working instance for participants to a workshop so that they can focus on solely extending through plugin but not the setup part.

The hope here also is to avoid the 24h npm review process, which is obviously not practical for a workshop format.

As argued before Manually check for plugin/theme updates · Issue #4735 · Chocobozzz/PeerTube · GitHub I believe this is not a security concern if it is not a default configuration setting but rather than an instance administrator has to first enable explicitly that behavior and because a person with access to install plugins anyway could do anything already.

Suggestions welcomed.

I also see that there is a Gitpod solution PeerTube/CONTRIBUTING.md at develop · Chocobozzz/PeerTube · GitHub and that makes me wonder how plugin development and testing works in that context.

Actually… maybe I don’t manage to understand the documentation correctly. I get the same error 400 on my local dev instance.

Hello,

The path argument should be the plugin path on the PeerTube instance, not the path on your local computer.

1 Like

So a copy via e.g scp or docker cp is required first?

I imagined the tooling was taking care of that but makes sense, I’ll try, thanks!

Well I must have another problem because I get the same error, 400, on a local development server. Logs don’t seem to clarify more beside being unable to find files despite directory being in the same file system, no container involved. I’ll double check permissions.

Hi, I have the same pb, except I’m trying to install a local plugin (the quickstart plugin I cloned from Framasoft / PeerTube / peertube-plugin-quickstart · GitLab) to a local Peertube instance on Docker. Everything’s fine following this tut until the « Then, you can install or reinstall your local plugin/theme by running » which breaks on the same « Error: Expected status 200, got 400 » error. To be precise my command is

node ./dist/server/tools/peertube.js plugins install --path /home/gregory/sources/peertube-plugins/updatevideo

It’s a plugin I need to install, it’s not on the Peertube instance yet, so I don’t understand @Chocobozzz answer. I attempted moving the plugin folder among my peertube instance files to try with a relative path, but it breaks with « Path should be absolute » error.
I understand this 400 error comes from the path argument as it shows too when the path is deliberately wrong, but I don’t know how I should set its value.

In your docker-compose.yml file, you can add a volume that points to your plugin:

version: "3.3"

services:
  peertube:
    image: chocobozzz/peertube:production-bullseye
    # [...]
    volumes:
      - ../peertube-plugin-livechat/:/peertube-plugin-livechat:ro
      # [...]

Here the path ../peertube-plugin-livechat/ is relative to your docker-compose file.

This will make your plugin dir available in the container, using the path /peertube-plugin-livechat.
I added the :ro option at the end, so the mount is read-only (the docker container won’t be able to change files in your dev directory).

Then, to install the plugin, you have 2 solutions.

If you have the peertube CLI on your computer

node ./dist/server/tools/peertube.js plugins install --path '/peertube-plugin-livechat' --url "http://localhost:9000"

Or, if you didn’t save your credentials with the CLI:

node ./dist/server/tools/peertube.js plugins install --path '/peertube-plugin-livechat' --url "http://localhost:9000" --username the_user_name --password the_password

If you want to use the CLI embedded in the docker container

I’m not using this method, so I’m not sure that it is the correct command, but it should look like (you must be in your docker dir):

docker-compose exec -u peertube node dist/server/tools/peertube.js plugins install --path '/peertube-plugin-livechat' # and maybe others parameters, I don't know if there are required here

Additionnal notes

Installing many times plugins can make the yarn cache to grow quickly.
You can flush it with:

docker-compose exec -u peertube peertube rm -rf /home/peertube/.cache/yarn
1 Like

Wow thanks so much @JohnLivingston, that worked perfectly!

You are welcome @GregRc :slight_smile:

Oh, I forgot one thing.

Sometime, by doing so, Peertube won’t work for a few seconds/minutes after restart, saying there is a missing plugin-globals.css file.
I did not understand yet why I have this error. I think it is because Peertube tries to update the plugins packages, and it can last a while.

To avoid that, just wait.
Or, if you don’t want, you can for example try:

docker-compose exec -u peertube touch /data/tmp/plugins-global.css

(just check the path, I’m not 100% sure it is the good one)

Ok, I hope I’ll remember that if it happens :sweat_smile:, thanks!

One easy way to remember, is to write a script to install your plugin. I use this one:

#!/bin/bash
set -euo pipefail

cd ~/dev/peertube_stuff/PeerTube
node ./dist/server/tools/peertube.js plugins uninstall --npm-name 'peertube-plugin-livechat' --url "http://localhost:9000" --username root --password '**********' && node ./dist/server/tools/peertube.js plugins install --path '/peertube-plugin-livechat' --url "http://localhost:9000" --username root --password '*************'
cd -

cd ~/dev/peertube_stuff/docker
docker-compose exec -u peertube peertube rm -rf /home/peertube/.cache/yarn
cd -

Where ~/dev/peertube_stuff/docker is the dev docker directory, and ~/dev/peertube_stuff/Peertube the directory where I built the CLI (you can replace the first command by the docker-compose equivalent).

PS: I always uninstall the plugin before installing it, because in some rare case I had bugs if I don’t do this. I don’t know if it is still the case with recent Peertube version, but I kept the uninstall command to avoid wasting time.