Platformio.ini can't open device " /dev/ttyUSB0"

I am trying to program ATtiny using VScode and PlatformIO.

In fact I have done this only a few days ago. Now when I try to upload I get:

avrdude: ser_open(): can’t open device " /dev/ttyUSB0": No such file or directory

Now, I know my permissions are correct. ArduinoISP for example, works - using the same programmer on the same port - also using avrdude! PuTTY also opens the port, no problem.

Here is my platform.ini code:

[env:program_via_ArduinoISP]
platform = atmelavr
framework = arduino
board = attiny85
upload_protocol = stk500v1
; each flag in a new line
upload_flags =
    -P $UPLOAD_PORT
    -b $UPLOAD_SPEED
    ;-U lfuse:w:0xE2:m
upload_speed = 19200
upload_port = /dev/ttyUSB0 ; Set the port

Hope you can help, thanks.

Prove it. Show the output of ls -la /dev/ttyUSB0 and id the moment before the upload button is pressed.

OK,

john@Dell2:~$ ls -la /dev/ttyUSB0
crw-rw----+ 1 root dialout 188, 0 Aug 12 09:59 /dev/ttyUSB0
john@Dell2:~$ id
uid=1000(john) gid=1000(john) groups=1000(john),4(adm),5(tty),20(dialout),24(cdrom),27(sudo),30(dip),46(plugdev),115(lpadmin),136(sambashare)

Then try to upload:

avrdude: ser_open(): can't open device " /dev/ttyUSB0": No such file or directory

avrdude done.  Thank you.

*** [upload] Error 1

Thinking about this overnight, I realised that last week I upgraded avrdude to the latest version. This was because switching from the ATtiny13 to the ATtiny85 caused a load of problems (incorrect device id, could not remove the DIV8 fuse, etc). After that nothing worked.

john@Dell2:~$ avrdude -v
Avrdude version 8.2-20260805 (bf86b97b)
Copyright see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

User configuration file is not provided

Error: no programmer has been specified on the command line or in the
config file(s); specify one using the -c option and try again

I assume avrdude in Arduino IDE works because it is an AppImage and is self-contained with its own version of avrdude. So, I am going to remove VScode and avrdude and install again from nothing. hopefully that will get things working properly!

The error shows a leading space before /dev/ttyUSB0.
Try to remove the inline comment first.
Use only upload_port = /dev/ttyUSB0.