question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run debug session as sudo

See original GitHub issue

Environment data

dotnet --info output: .NET Command Line Tools (2.0.0)

Product Information: Version: 2.0.0 Commit SHA-1 hash: cdcd1928c9

Runtime Environment: OS Name: ubuntu OS Version: 16.04 OS Platform: Linux RID: ubuntu.16.04-x64 Base Path: /usr/share/dotnet/sdk/2.0.0/

Microsoft .NET Core Shared Framework Host

Version : 2.0.0 Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

VS Code version: 1.17.2 b813d12980308015bcd2b3a2f6efa5c810c33ba5

C# Extension version: 1.12.1

Steps to reproduce

  1. Create a console project.
  2. Execute bash command in code that requires sudo permission

Expected behavior

command to be executed with root privilege.

Actual behavior

permission denied error

I have looked in launch settings documentation and also intellisense but I cannot see anywhere to set my debug launch options to use sudo. The work around is to launch VS Code as root but I have seen other languages vs code debuggers like python have ability to set it as a launch parameter for debugging session.

Is there any way to do this?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisrickardcommented, Feb 6, 2018

FYI, it worked for me by throwing sudo in front of the debuggerPath, not ideal, bujt allowed me to debug.

E.g.

            "pipeTransport": {
                "pipeCwd": "${workspaceRoot}",
                "pipeProgram": "ssh",
                "pipeArgs": [ "vagrant@127.0.0.1", "-p2222", "-i ${workspaceRoot}/.vagrant/machines/default/virtualbox/private_key" ],
                "debuggerPath": "sudo ~/vsdbg/vsdbg",
                "quoteArgs": false
            },
1reaction
gregg-miskellycommented, Oct 27, 2017

@GuerrillaCoder from what I can tell, gksudo will not redirect stdin/out across, so it might be possible for the extension to use it internally to add this feature, but it wouldn’t work as a pipeTransport. Thinking more, sudo wouldn’t work as there would be no way to pass in the password. I think the only thing that could work today would be to SSH into your own computer as root.

I will leave this open as a feature request. I think we could do this without too much effort by running sudo in the VS Code terminal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to debug programs with "sudo" in VSCODE
When first running a debug session, VSCode creates a terminal called e.g. Debug: Main . Just open the terminal, press Ctrl+C, type sudo...
Read more >
A.2. Troubleshooting sudo with SSSD and sudo Debugging ...
Run the sudo command as the user you want to debug. The /var/log/sudo_debug.log file is created automatically and provides detailed information to answer ......
Read more >
[Solved]-How to debug programs with "sudo" in VSCODE-C++
When first running a debug session, VSCode creates a terminal called e.g. Debug: Main . Just open the terminal, press Ctrl+C, type sudo...
Read more >
Sudo Logging and Monitoring
Full session capture (/var/log/sudo-io) ... Debug sudo applies to both sudo and sudoers. ... Run a command as sudo. For example sudo ls...
Read more >
How to run / debug programs with super user privileges
What's the easiest way to run (and debug) a script/program from PyCharm with super user privleges (i.e. sudo)? FYI, I don't want to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found