formulahendry / vscode-code-runner

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

[Bug] -Windows shellscript executorMap not being honored. #987

Open shotah opened 1 year ago

shotah commented 1 year ago

Describe the bug Trying to change how shellscripts run to be able to quickly use code runner. I've tried setting different options in settings but nothing changes.

  "code-runner.executorMap": {
    "shellscript": "cd $dir && sh $fileName",
  }

To Reproduce Steps to reproduce the behavior:

  1. Set anything in executor map for shellscript
  2. Try to run a bash file
  3. Get the original message and settings are not honored.

Actual behavior Always get the EXACT same message, not matter how I change shellscript

[Running] /bin/bash "c:\workspace\test"
The system cannot find the path specified.

Expected behavior To be able to set variables and enable shellscripts to work with code runner.

fvydjt commented 1 year ago

I had the same question. But I solved it just now. Your script may have the #!/bin/bash at the first line, which causes the bash interpreter to be fixed. So, just remove this line. Then, your custom command can take effect instantly.


By the way, it is controlled by this code-runner option.

zhuoqun-chen commented 1 year ago

I just encountered the same problem and I removed "#!/bin/bash" then the code-runner will work like a charm. Thanks!

fanlushuai commented 9 months ago

removed the line. still error below

(base) PS E:\code\open\ahks> bash  "e:\code\open\ahks\publish.sh"
/bin/bash: e:codeopenahkspublish.sh: No such file or directory

and found code run config for bash is:

   "shellscript": "bash ",

change to :

   "shellscript": "bash  $fileName",

it works

zjh-de-github commented 2 months ago

I had the same question. But I solved it just now. Your script may have the #!/bin/bash at the first line, which causes the bash interpreter to be fixed. So, just remove this line. Then, your custom command can take effect instantly.

By the way, it is controlled by this code-runner option.

Thank you! It works!