Search code examples
visual-studio-codevscode-remote

How to run task using sudo


I'd like to create a task in VS Code for starting/stopping my postgres server. Is it possible to run a task using sudo?

For example, sudo service postgresql start?

I've tried the following launch config but it fails with an error that it can't load such file.

        {
            "name": "Start Postgres server",
            "type": "Ruby",
            "request": "launch",
            "program": "sudo service postgresql start"
        }

Solution

  • Try to change the type property from Ruby to the shell.

            {
            "name": "Start Postgres server",
            "type": "shell",
            "request": "launch",
            "program": "sudo service postgresql start"
            }
    

    Read more about tasks here.