Klipper

Can’t see /tmp/printer and not connect

Klipper by default adds a link /tmp/printer pointing to the correct device to connect to. If that link is owned by a different user then repetierserver and the /tmp folder has the +t flag set, we can not read and open the link due to permission problems. In that case you can either reference the device directly – normally /dev/pts/1 and everything will work.

Solution 1

If you have multiple klipper instances so it is not clear which device will point to which pts device, you can tell klipper where to place that link with -I flag.

New systemd solution

Current klipper versions use a systemd service file to create a service. Here the solution is to change the user running klipper to “repetierserver” and the permission problems with /tmp/printer are gone. So log in via ssh and follow the instructions.

Stop klipper service

sudo service klipper stop

Edit klipper service to run as user repetierserver

sudo nano /etc/systemd/system/klipper.service

Replace old content

#Systemd service file for klipper
[Unit]
Description=Starts klipper on startup
After=network.target

[Install]
WantedBy=multi-user.target

[Service]
Type=simple
User=pi
RemainAfterExit=yes
ExecStart=/home/pi/klippy-env/bin/python /home/pi/klipper/klippy/klippy.py /home/pi/printer.cfg -l /tmp/klippy.log
Restart=always
RestartSec=10#Systemd service file for klipper
[Unit]
Description=Starts klipper on startup
After=network.target

Into the following one where we only changed the User= line:

[Install]
WantedBy=multi-user.target

[Service]
Type=simple
User=repetierserver
RemainAfterExit=yes
ExecStart=/home/pi/klippy-env/bin/python /home/pi/klipper/klippy/klippy.py /home/pi/printer.cfg -l /tmp/klippy.log
Restart=always
RestartSec=10

Remove old files which were created by the user “pi”

sudo rm /tmp/klippy.log
sudo rm /tmp/printer

Recreate the service and start klipper

sudo systemctl daemon-reload
sudo service klipper start

Now you can select /tmp/printer as serial device in Repetier-Server and connection should work.

Old init.d solution

Older klipper versions used a service defined in /etc/init.d/klipper – for these use this solution-

Default is in /etc/default/klipper and can be changed there. So create a folder writeable by Klipper, e.g.

sudo mkdir /var/lib/klipper
sudo chmod 777 /var/lib/klipper

And then modify in /etc/default/klipper

KLIPPY_ARGS="/home/pi/klipper/klippy/klippy.py /home/pi/printer.cfg -l /tmp/klippy.log"

into

KLIPPY_ARGS="/home/pi/klipper/klippy/klippy.py /home/pi/printer.cfg -l /tmp/klippy.log -I /var/lib/klipper/connect"

And then also enter /var/lib/klipper/connect manually in Repetier-Server port name. After restarting Klipper Repetier-Server should now see the link and open it without problems.

Alternative solution

The alternative solution that works as well as the replaced link is to start klipper as repetierserver user. Edit /etc/default/klipper and set

KLIPPY_USER=repetierserver

and restart klipper. Now both have the same user and no permission problems exist.