VS Code: Exercism Commands Fail with "need to run as root or suid" Error

Exercism CLI commands fail to run within the VS Code integrated terminal, resulting in the error message “need to run as root or suid.” This behavior occurs in recent VS Code versions and likely extends to other environments with stricter privilege controls.

Expected Behavior:

Exercism commands should function normally within the VS Code terminal without requiring root or suid privileges.

Actual Behavior:

Any Exercism CLI command executed in the VS Code terminal throws the “need to run as root or suid” error. This behavior persists even when opening new terminal instances from within VS Code.

Steps to Reproduce:

  1. Open a project in VS Code.
  2. Access the integrated terminal.
  3. Attempt to run an Exercism command (e.g., exercism submit ).

Additional Information:

  • This issue likely relates to recent changes in VS Code as it enforces no-new-privileges for itself and child processes, for security reasons, according to them.
  • Users should not need root access for basic Exercism functionality.
  • My environment:
    • DISTRIB_ID=Ubuntu
      DISTRIB_RELEASE=22.04
      DISTRIB_CODENAME=jammy
      DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"
      
    • Visual Studio Code:
      Version: 1.90.2
      Commit: 5437499feb04f7a586f677b155b039bc2b3669eb
      Date: 2024-06-18T22:33:48.698Z
      Electron: 29.4.0
      ElectronBuildId: 9728852
      Chromium: 122.0.6261.156
      Node.js: 20.9.0
      V8: 12.2.281.27-electron.0
      OS: Linux x64 5.15.0-112-generic  
      
    • exercism version: 3.0.13
1 Like

I’m pretty sure the exercism command hasn’t had any significant recent changes. What happens if you run the command from a terminal independent of VSCode?

For the record, I have the exact same version of VSCode and the latest Exercism CLI version. I tried to reproduce this both in Windows and Ubuntu and couldn’t; running exercism submit works as expected.

Is it possible that your exercism binary is under a different user? I don’t really know why this would matter though. (I would probably be at the end of my Linux knowledge there so maybe someone else has an idea.)

Maybe it was installed with sudo or placed in a sudo path or some such?

It works alright:

It’s actually Snap package:

$ which exercism 
/snap/bin/exercism

I suppose it updates automatically, right?

Thx for the clue. i’ll look more into it…

You might want to try logging off and back on and trying again. If exercism works in the terminal, then exercism is working. Any issues might be VSCode issues.

1 Like

How do I know it has to do with privilege restrictions? When I run from VSCode:

$ sudo
sudo: The "no new privileges" flag is set, which prevents sudo from running as root.
sudo: If sudo is running in a container, you may need to adjust the container configuration to disable the flag.

By the way, VSCode is installed via apt:

$ apt policy code
code:
  Installed: 1.90.2-1718751586
  Candidate: 1.90.2-1718751586
  Version table

Are you running sudo from VSCode? sudo shouldn’t be involved anywhere, other than to sudo apt-get install exercism if you install it that way.

1 Like

Not really. I just noticed it when I tried submitting 2th iteration on an exercise I did. Googling led me to sudo being restricted, which is what I tested just to make sure…

Sudo used to work fine, well, it still works well enough from code-server… Vut code itself hasn’t given me this issue, since using Exercism again…

Worth noting that we have always seen lots of problems with snap which is why we don’t officially recommend it any more. Not sure if that’s related here, but just FYI.

1 Like

Just got rid of Snap version in order to install from brew, which appears to work well, and no privileges or sudo BS.

It seems I’m done with this one, tho I need to set it up again

1 Like