'runhaskell' is not recognized as an internal or external command, operable program or batch file

Viewed 4140

I installed Haskell on Windows with these commands:

  1. Set-ExecutionPolicy Bypass -Scope Process -Force; 
    [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
    iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
    
  2. choco install haskell-dev
    

After install successfully I write the code on VSCode and try to run the code with the help of code runner it gives me this error:

'runhaskell' is not recognized as an internal or external command, operable program or batch file.

How to solve this problem ?

2 Answers

ghc --version 9.0.1 did not have runhaskell.If you want to run your code in vs code through coderunner than go into vs code setting->coderunner->setting.jason in "code-runner.executorMap" write "runghc" instead of "runhaskell" like "code-runner.executorMap": {"haskell": "runghc",}

Hussmansindu was right with his response. Although the setup in VSCode may sound confusing, You would be able to run Haskell code in VSCode when running it with the "ghc" base.

VSCode default set up for running it was "runhaskell," whereas you need "runghc." To do so, please follow the following approach step-by-step.

In VSCode, while on any file you want to run:

  1. Use your keyboard and press "Ctrl ," ( press the control key and the comma key simultaneously). By doing so, you are about to access the setting page.

  2. You have prompted the setting page to open and will see something like this image below: Valid XHTML.

  3. In the search setting field as depicted in the image please, enter the keyword "code runner" as shown below and locate the "code-runner: Executor Map By File Extension" as illustrated in the image, then click the Edit in settings.json link Valid XHTML.

  4. Then, the setting page will be prompted and as depicted below. Locate the line "haskell": "runhaskell" and change it to "haskell": "runghc" as shown in the snap below Valid XHTML.

  5. Press Ctrl S to save the setting and close the window.

  6. Now, try to run the Haskell file.

I hope my explanation helps.

Many regards.

Ola

Related