skip to Main Content

I am trying to compile .c file in VS Code terminals, but when executing

gcc test.c -o test.exe

the VS Code external terminal will yield this error:

Assembler messages:
Fatal error: can't create C:Users

However, executing the above code in a normal terminal will work just fine.

I am using Windows 11 and the GCC is built using MSYS2. I want to emphasize that I am not using the integrated terminal, and integrated terminal yielded the same error.

So far I have tried

  1. Using different shells. I have tried powershell, git bash, and cmd; all of them yield the same results.

  2. give admin permission to vs code, but the same error persists.

2

Answers


  1. 1. Check Default Shell:
    Verify that the default shell used by VS Code’s integrated terminal is the same as the shell you’re using in the separate terminal window. To check and change the default shell in VS Code:

    Open the command palette (Ctrl + Shift + P).
    Type "Select Default Shell" and choose the shell you want to use.
    Restart VS Code and try compiling again.
    Check Terminal Profile:
    Ensure that the terminal profile you’re using in VS Code’s integrated terminal is configured correctly. Sometimes, different terminal profiles can have different configurations (like environment variables, paths, etc.).

    Login or Signup to reply.
  2. Electron can be a little finnicky sometimes so you can try killing all instances of vscode in task manager manually and then running as administrator again and if that doesn’t work try Set-ExecutionPolicy Unrestricted in the terminal.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search