So I ran into a little problem programming the Arduino Leonardo via the Arduino-CLI on the Raspberry PI and I thought I'd share what I did to make it work. Seems like there is a program called ModemManager that pings the Leonardo and prevents uploading.
When googling the error I got to this thread on github for Arduino IDE problems on Linux distributions, which Raspbian for Raspberry PI is. https://github.com/arduino/Arduino/issues/7690
#remove the troublemaker sudo apt-get remove modemmanager # remove packages that aren't needed anymore sudo apt-get autoremove