Search code examples
erlangvisual-studio-codeerlang-shell

Erlang not working with internal Terminal in Visual Studio Code


I am currently having an issue with visual studio code and erlang, I have erlang/OTP installed on my PC, and I have installed the erlang plugin for visual studio code, however I cannot run erlang from the internal terminal window. When I try to I receive this error:

erl : The term 'erl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:1
+ erl
+ ~~~
+ CategoryInfo          : ObjectNotFound: (erl:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

any help would be appreciated.


Solution

  • From the VS docs

    The shell [that is] used [by VS] defaults to $SHELL on Linux and OS X, and %COMSPEC% on Windows. These can be overridden manually by setting terminal.integrated.shell.* in settings.

    So I would check what the value is of your %COMSPEC% environment variable. Or, you can override %COMSPEC% in the VS settings:

    From the VS docs:

    Correctly configuring your shell on Windows is a matter of locating the right executable. VS Code defaults to the %COMSPEC% environment variable on Windows which typically points to the 32-bit version of cmd.exe.

    Below are a list of common shell executables and their default locations:

    // 64-bit cmd if available, otherwise 32-bit
    "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe"
    // 64-bit PowerShell if available, otherwise 32-bit
    "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
    // Git Bash
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
    // Bash on Ubuntu (on Windows)
    "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
    

    You may also want to check if the path to erlang is in your %PATH% environment variable, and if not add it. Have you ever successfully started up the erlang shell before, e.g. after you installed erlang to test that it was working?