VS Code and sudo on Raspberry Pi

Viewed 27

I'm developing C code on a Raspberry Pi that uses the pigio library to access GPIO pins and I2C and SPI busses. The source code is in my user space, but program execution requires sudo to get the necessary privileges to execute. I would like to use the debugging facilities in VS Code haven't found a way to get it to launch with privileges.

I found two references on stack overflow but neither worked for me.

I tried "sudo": true in the launch script but it didn't allow the program to launch.

I also tried from the source directory

sudo "your-directory" --user-data-dir='.' --no-sandbox

but it also didn't allow the program to launch

I saw this note in another online post on stack overflow:

sudo code myfile stopped working sometime in July/August 2021

How can I debug or even execute code that requires root privileges within VS Code?

1 Answers

You can run vscode as root using :

$ sudo code 

If it doesn't work, you can also use the following (Warning : this is not good practice) :

$ chmod 777 YOUR_FILE
Related