formulahendry / vscode-code-runner

Code Runner for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner
MIT License
2.19k stars 292 forks source link

Cannot run .exe files #337

Open Salil03 opened 6 years ago

Salil03 commented 6 years ago

Here is a part of my settings.json

"code-runner.executorMapByFileExtension": {
        ".vb": "cd $dir && vbc /nologo $fileName && $dir$fileNameWithoutExt",
        ".vbs": "cscript //Nologo",
        ".scala": "scala",
        ".jl": "julia",
        ".cr": "crystal",
        ".ml": "ocaml",
        ".exs": "elixir",
        ".hx": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
        ".rkt": "racket",
        ".ahk": "autohotkey",
        ".au3": "autoit3",
        ".kt": "cd $dir && kotlinc $fileName -include-runtime -d $fileNameWithoutExt.jar && java -jar $fileNameWithoutExt.jar",
        ".kts": "kotlinc -script",
        ".dart": "dart",
        ".pas": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        ".pp": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        ".d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
        ".hs": "runhaskell",
        ".nim": "nim compile --verbosity:0 --hints:off --run",
        ".csproj": "dotnet run --project",
        ".fsproj": "dotnet run --project",
        ".exe": "cd $dir && $fileName"
    }

But when I right click on an .exe an click run code, nothing happens. What am I doing wrong ?

OS: Windows 10 64-bit VS Code: Version 1.25

formulahendry commented 6 years ago

Did you see anything as below? You may want to open VS Code as admin image

Salil03 commented 6 years ago

No I didn't see anything like that

Salil03 commented 6 years ago

And it doesn't work even if I run it as administrator.

formulahendry commented 6 years ago

What if you run other types of code?

Salil03 commented 6 years ago

.cpp works and .py also works

Salil03 commented 6 years ago

code-runner.executorMapByFileExtension does not work but all programming languages work

formulahendry commented 6 years ago

Could you have a screenshot of your settings?

Salil03 commented 6 years ago
{
    "git.ignoreMissingGitWarning": true,
    "terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
    "code-runner.executorMap": {
        "javascript": "node",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "cpp": "cd $dir && \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\Common7\\Tools\\VsDevCmd.bat\" && cl.exe /EHsc /W3 /std:c++latest \"$fileName\" && del \"$fileNameWithoutExt.obj\" && cls && \"$fileNameWithoutExt.exe\"",
        "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "php": "php",
        "python": "cd $dir && python \"$fileName\"",
        "perl": "perl",
        "perl6": "perl6",
        "ruby": "ruby",
        "go": "go run",
        "lua": "lua",
        "groovy": "groovy",
        "powershell": "powershell -ExecutionPolicy ByPass -File",
        "bat": "cmd /c",
        "shellscript": "bash",
        "fsharp": "fsi",
        "csharp": "scriptcs",
        "vbscript": "cscript //Nologo",
        "typescript": "ts-node",
        "coffeescript": "coffee",
        "scala": "scala",
        "swift": "swift",
        "julia": "julia",
        "crystal": "crystal",
        "ocaml": "ocaml",
        "r": "Rscript",
        "applescript": "osascript",
        "clojure": "lein exec",
        "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
        "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
        "racket": "racket",
        "ahk": "autohotkey",
        "autoit": "autoit3",
        "dart": "dart",
        "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
        "haskell": "runhaskell",
        "nim": "nim compile --verbosity:0 --hints:off --run",
        "executable": "cd $dir && $fileName"
    },
    "code-runner.runInTerminal": true,
    "code-runner.saveFileBeforeRun": true,
    "C_Cpp.clang_format_style": "VIsual Studio",
    "C_Cpp.loggingLevel": "Error",
    "python.autoComplete.addBrackets": true,
    "python.globalModuleInstallation": true,
    "editor.cursorStyle": "line",
    "editor.dragAndDrop": false,
    "editor.emptySelectionClipboard": false,
    "editor.fontFamily": "'Hasklig', Consolas, monospace",
    "editor.fontLigatures": true,
    "editor.fontSize": 16,
    "editor.formatOnPaste": true,
    "editor.formatOnSave": true,
    "editor.formatOnType": true,
    "editor.smoothScrolling": true,
    "terminal.integrated.rightClickBehavior": "default",
    "macros": {
        "inline": [
            "jupyter.runSelectionLine",
            "cursorDown"
        ]
    },
    "git.autofetch": false,
    "git.autoRepositoryDetection": false,
    "git.autorefresh": false,
    "git.enabled": false,
    "workbench.colorTheme": "Adapta Nokto",
    "files.autoGuessEncoding": true,
    "window.zoomLevel": 0,
    "media.player": {
        "players": [
            {
                "name": "My VLC player",
                "type": "vlc",
            }
        ]
    },
    "C_Cpp.clang_format_path": "clang-format",
    "C_Cpp.default.intelliSenseMode": "msvc-x64",
    "C_Cpp.default.cStandard": "c11",
    "C_Cpp.default.cppStandard": "c++14",
    "code-runner.executorMapByFileExtension": {
        ".vb": "cd $dir && vbc /nologo $fileName && $dir$fileNameWithoutExt",
        ".vbs": "cscript //Nologo",
        ".scala": "scala",
        ".jl": "julia",
        ".cr": "crystal",
        ".ml": "ocaml",
        ".exs": "elixir",
        ".hx": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
        ".rkt": "racket",
        ".ahk": "autohotkey",
        ".au3": "autoit3",
        ".kt": "cd $dir && kotlinc $fileName -include-runtime -d $fileNameWithoutExt.jar && java -jar $fileNameWithoutExt.jar",
        ".kts": "kotlinc -script",
        ".dart": "dart",
        ".pas": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        ".pp": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        ".d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
        ".hs": "runhaskell",
        ".nim": "nim compile --verbosity:0 --hints:off --run",
        ".csproj": "dotnet run --project",
        ".fsproj": "dotnet run --project",
        ".exe": "cd $dir && $fileName"
    },
    "files.associations": {
        ".exe": "executable"
    }
}

This is the settings.json

formulahendry commented 6 years ago

What if you run .csproj file?

Salil03 commented 6 years ago

How do I do that ?

formulahendry commented 6 years ago

Just create a abcd.csproj file with any content, then Run Code

Salil03 commented 6 years ago

Ok. I will do that in some time. Thanks for your help.

Salil03 commented 6 years ago

Yes it works

formulahendry commented 6 years ago

Could you remove below setting and try again?

"files.associations": {
        ".exe": "executable"
    }

And when you run .exe, nothing in Output Channel? And could you see any error in Help->Toggle Developer Tools->Console?

Salil03 commented 6 years ago

After I remove the setting the same thing happens.

I see nothing in the Output Channel

Here is what I see in Developer Tools Console:

ERR cannot open file:///c%3A/Users/prash/Documents/Salil/Programming/Programs/C%2B%2B/Exercises/Chapter%203/Ex%2011.exe. Detail: File seems to be binary and cannot be opened as text: Error: cannot open file:///c%3A/Users/prash/Documents/Salil/Programming/Programs/C%2B%2B/Exercises/Chapter%203/Ex%2011.exe. Detail: File seems to be binary and cannot be opened as text
    at file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:4150:832
    at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:375)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
    at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
    at n.Class.derive._creator._chainedError (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:255)
    at n (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:115)
    at n.Class.define.cancel.then (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:156:736)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:184)
    at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
    at n.Class.derive._creator._setCompleteValue (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:590)
    at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:357)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
    at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
    at n.Class.derive._creator._chainedError (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:255)
    at n (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:115)
    at n.Class.define.cancel.then (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:156:736)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:184)
    at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
    at n.Class.derive._creator._setCompleteValue (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:590)
    at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:357)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
    at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
    at n.Class.derive._creator._chainedError (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:255)
    at n (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:115)
    at n.Class.define.cancel.then (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:156:736)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:184)
    at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
    at n.Class.derive._creator._setCompleteValue (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:590)
    at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:357)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
    at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
    at n.Class.derive._creator._chainedError (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:255)
    at n (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:115)
    at n.Class.define.cancel.then (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:156:736)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:184)
    at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
    at n.Class.derive._creator._setCompleteValue (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:590)
    at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:357)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
    at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
    at n.Class.derive._creator._chainedError (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:255)
    at n (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:115)
    at n.Class.define.cancel.then (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:156:736)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:153:184)
    at n.Class.derive._creator._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
    at n.Class.derive._creator._setCompleteValue (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:590)
    at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:357)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
    at n.Class.derive._oncancel._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
    at n.Class.derive._oncancel._error (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:413)
    at l (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:158:962)
    at file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:159:70
    at Object.v [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:151:375)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:154:592)
    at n.Class.derive._oncancel._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:896)
    at n.Class.derive._oncancel._error (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:155:413)
    at v (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:3174:344)
    at file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:3175:224
    at n.Class.define.cancel.then (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:157:366)
    at file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:3175:172
    at callback (C:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\graceful-fs\polyfills.js:128:19)
    at FSReqWrap.wrapper [as oncomplete] (original-fs.js:629:17)
Salil03 commented 6 years ago

Did you find a solution ?

formulahendry commented 6 years ago

Oh, I could repro this issue now. This is a bug. I will take a look at this.

Salil03 commented 6 years ago

Thank You

Salil03 commented 6 years ago

When will it be corrected ? Is there a alternative currently ?

formulahendry commented 6 years ago

You could use "code-runner.customCommand" as workaround

Salil03 commented 6 years ago

How do I use that because when I tried it, even that was not working

formulahendry commented 6 years ago

"code-runner.customCommand": "foo/bar/abc.exe"

Salil03 commented 6 years ago

what does foo/bar/abc.exe mean ? I want it for any exe file with any name

formulahendry commented 6 years ago

In that case, there is no good workaround.

Salil03 commented 6 years ago

Ok when will the bug be repaired

Salil03 commented 6 years ago

and what exactly does the error message mean ?

Salil03 commented 6 years ago

The funny thing is that it used to work 3 months earlier!

formulahendry commented 6 years ago

Seems VS Code has API change, .exe would not be opened by default now. If you open a .exe file as a text, then you could run it.

Salil03 commented 6 years ago

How do I open .exe as a text ?

formulahendry commented 6 years ago

image

Salil03 commented 6 years ago

Ok thanks :)

Salil03 commented 6 years ago

Just for my curiosity, when are you planning to fix the bug ?

formulahendry commented 6 years ago

No ETA for now. If you'd like to have a PR to fix that, that would be great. :)

Salil03 commented 6 years ago

What is a PR

Salil03 commented 6 years ago

Does it mean Pull Request

formulahendry commented 6 years ago

Yes

Salil03 commented 6 years ago

I don't think I have the knowledge to fix the bug. Sorry 😔☹️

aandrejevas commented 1 year ago

Hello, any progress on this issue? I encountered the same problem.

mturvillehei commented 1 year ago

I've also run into this problem.

Kavex71 commented 1 year ago

No. If I'm worse, I'm new to this, I barely understand a little, I really want to learn and I'm trying hard every day.