Hello PeerTubers,
I have tried a clean install, but have hit a wall when trying to enable the PeerTube service. The error is:
peertube.service: Changing to the rwequested working directory failed: No such file or directory
peertube.service: Failed at step CHDIR spwaning /usr/bin/node: No such file or directory
I have looked back through the instructions a few times to try and work out what I have done wrong, but am none the wiser. My peertube.service file content is below.
If someone can offer guidance it would be appreciated.
Kind Regards,
RW
[Unit]
Description=PeerTube daemon
After=network.target postgresql.service redis-server.service
[Service]
Type=simple
Environment=NODE_ENV=production
Environment=NODE_CONFIG_DIR=/var/www/peertube/config
User=peertube
Group=peertube
ExecStart=/usr/bin/node dist/server
WorkingDirectory=/var/www/peertube/peertube-latest
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=peertube
Restart=always
; Some security directives.
; Mount /usr, /boot, and /etc as read-only for processes invoked by this service.
ProtectSystem=full
; Sets up a new /dev mount for the process and only adds API pseudo devices
; like /dev/null, /dev/zero or /dev/random but not physical devices. Disabled
; by default because it may not work on devices like the Raspberry Pi.
PrivateDevices=false
; Ensures that the service process and all its children can never gain new
; privileges through execve().
NoNewPrivileges=true
; This makes /home, /root, and /run/user inaccessible and empty for processes invoked
; by this unit. Make sure that you do not depend on data inside these folders.
ProtectHome=true
; Drops the sys admin capability from the daemon.
CapabilityBoundingSet=~CAP_SYS_ADMIN
[Install]
WantedBy=multi-user.target
Further to this. After restarting some services, I am now getting the error:
Started PeerTube Daemon.
peertube.service: Main process exited, code-exited, status=203/EXEC
peertube.service: Failed with result 'exit-code'.
peertube.service: Service hold-off time over, scheduling restart.
peerrtube.service: Scheduled restart job, restart counter is at 5.
StoppedPeerTube Daemon.
peersube.service: Start request repeated too quickly.
peertube.service: Failed with result 'exit-code'/
Failed to start PeerTube daemon.
Did you do sudo systemctl daemon-reload
after writing the service file?
Is Peertube in the folder /var/www/peertube
?
What is the output of: sudo journalctl -feu peertube
just after the peertube restart?
Dr Livingston I presume? 
Thank you for the reply.
I did run the daemon reload after writing the service file. I just ran it again in case I was mistaken.
I think PeerTube is in the /var/www/ folder, but a number of what look like key files also appear to be in /var/www/peertube/peertube-latest
I ran the feu command and found the below. It seems to be looking for a module in /var/www/peertube/versions/PeerTube-develop/server
I initially couldn’t get PeerTube to install using
sudo -u peertube wget -q "https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip"
So I manually uploaded a ZIP of PeerTube-develop.zip (which seems to be responsible for that directory). But then deleted the PeerTube directory and started again. Perhaps that is the start of the trouble?
If this hasn’t work, it is maybe because you forgot to set the VERSION var. See in the official documentation:
VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) && echo "Latest Peertube version is $VERSION"
This set the variable VERSION to the latest available version.
Then, if you do echo $VERSION
, you should see 3.2.1 as a result.
Then the download command should work.
Warning: you MUST do all commands in the same terminal as the VERSION=… command. Bash variable are not permanent.
Later on the procedure, you will have to create a symbolic link /var/www/peertube/peertube-latest
pointing to the downloaded source code.
These lines in the documentation:
$ cd /var/www/peertube
$ sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest
$ cd ./peertube-latest && sudo -H -u peertube yarn install --production --pure-lockfile
Notice that the $VERSION variable has to be set!
If it was not, then this link creation will fail.
You can check this symbolic link with:
ls -l /var/www/peertube
You should see something like this:
$ ls -l /var/www/peertube
total 16
drwxr-xr-x 3 peertube peertube 4096 Jun 1 14:19 backup
drwxr-xr-x 2 peertube peertube 4096 May 30 18:33 config
lrwxrwxrwx 1 peertube peertube 43 Jun 1 14:20 peertube-latest -> /var/www/peertube//versions/peertube-v3.2.1
drwxr-xr-x 16 peertube peertube 4096 Jun 21 08:24 storage
drwxr-xr-x 32 peertube peertube 4096 Jun 1 14:20 versions
If the line with peertube-latest
is not like that (pointing to /var/www/peertube//versions/peertube-v3.2.1), this is your problem.
Hmm, well I think then that I did follow the version setup correctly then as I am seeing:
and what is in this directory? ls -al /var/www/peertube/peertube-latest
Oops, sorry, I forgot a /
ls -al /var/www/peertube/peertube-latest/
To check the content of the symbolic link directory.
Should be:
$ ls -al /var/www/peertube/peertube-latest/
total 500
drwxr-xr-x 8 peertube peertube 4096 Jun 1 14:20 .
drwxr-xr-x 32 peertube peertube 4096 Jun 1 14:20 ..
-rw-r--r-- 1 peertube peertube 8773 Jun 1 09:08 CREDITS.md
-rw-r--r-- 1 peertube peertube 38 May 28 11:51 FAQ.md
-rw-r--r-- 1 peertube peertube 34520 Apr 10 2019 LICENSE
-rw-r--r-- 1 peertube peertube 9963 Jun 1 09:08 README.md
drwxr-xr-x 4 peertube peertube 4096 Jun 1 14:20 client
drwxr-xr-x 2 peertube peertube 4096 Jun 1 09:08 config
drwxr-xr-x 5 peertube peertube 4096 Jun 1 09:12 dist
drwxr-xr-x 675 peertube peertube 20480 Jun 1 14:20 node_modules
-rw-r--r-- 1 peertube peertube 7456 Jun 1 09:03 package.json
drwxr-xr-x 10 peertube peertube 4096 Jun 1 09:08 scripts
drwxr-xr-x 10 peertube peertube 4096 Aug 12 2020 support
-rw-r--r-- 1 peertube peertube 813 Aug 12 2020 tsconfig.json
-rw-r--r-- 1 peertube peertube 382201 May 28 11:51 yarn.lock
Not at all. I missed that too when I ran the query. 
The symbolic link directory has all those files:

I don’t think this should make any difference, but in the spirit of full disclosure I have Mastodon running on the same VPS.
Must be a simple mistake…
Have you upgraded node version at some time? (if so, you have to call again the yarn install --pure-lock
command).
Otherwise, just check the installation procedure point by point.
Try to set the log level to debug in production.yml, and see what is displayed when: sudo systemctl restart peertube && sudo journalctl -feu peertube
I think we have it. In flailing around to try and fix it myself, I must have upgraded node. Re-running yarn install seems to have the PeerTube application running!
But as Henry Kissinger once noted: success is only the admission ticket to the next crisis.
I am now seeing the error that PeerTube was started (and created some data) with another domain name. I then fixed this by updating the actors with:
NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host
But now I can’t access the site as I have a blocked host error. Time to do some more reading…
If it is a new instance, it will be simplier to delete database and peertube/storage subfolders contents.
Thanks for the tip, yes it is a new site.
But the issue seems to be with the domain setup:
Blocked host: videos.winter.ink
To allow requests to videos.winter.ink, add the following to your environment configuration:
config.hosts << « videos.winter.ink »
It seems there is no IPv4 for this domain. Maybe it is related?
$ dig videos.winter.ink
; <<>> DiG 9.11.5-P4-5.1+deb10u5-Debian <<>> videos.winter.ink
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16855
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;videos.winter.ink. IN A
;; AUTHORITY SECTION:
winter.ink. 3552 IN SOA nsany1.infomaniak.com. hostmaster.infomaniak.ch. 2021063002 10800 3600 605800 3600
;; Query time: 3 msec
;; SERVER: 80.67.169.12#53(80.67.169.12)
;; WHEN: mer. juin 30 15:06:16 CEST 2021
;; MSG SIZE rcvd: 127
Many thanks for digging into something that wasn’t part of my original request. Above any beyond. 
You could be right about IPv4. But I understand that IPv6 is replacing the old IPv4 and so am trying to configure my DNS only using IPv6. Perhaps it can’t be done, but initial research suggests it should…