Debug a C# or Python program outside the environment

When I try to debug a C# or Python program in Visual Studio Code in an external terminal (with bash) it gives me the following error:

/usr/bin/bash: cannot execute binary file

after seeing that error I try to call bash from the Manjaro console with the executable file:

bash executable

and it gave me the same error that visual studio code showed. I was only able to run the file without getting an error with the following command:

bash -c executable

Now the questions I have are the following:

  • Why VSCode neither in Ubuntu nor in Manjaro Gnome (which I had installed last week) did not give me this error and in Manjaro KDE it did?
  • How can I fix this problem?

Any help or advice is very welcome

Note: With VSCode’s internal terminal I have no errors (which is very rare) and although I can work normally with the internal terminal, I still prefer the external one with which I am adapted.

Info about my System:

Visual Studio Code version → 1.59

inxi --admin --verbosity=7 --filter --no-host --width
System:
  Kernel: 5.13.11-1-MANJARO x86_64 bits: 64 compiler: gcc v: 11.1.0 
  parameters: BOOT_IMAGE=/boot/vmlinuz-5.13-x86_64 
  root=UUID=a019a34f-6d74-4928-9cef-fbe5668e2e4a rw quiet apparmor=1 
  security=apparmor udev.log_priority=3 
  Console: tty pts/4 wm: kwin_x11 DM: SDDM Distro: Manjaro Linux 
  base: Arch Linux 
Machine:
  Type: Laptop System: Acer product: Predator G3-572 v: V1.10 serial: <filter> 
  Mobo: KBL model: Sienta_KLS v: V1.10 serial: <filter> UEFI: Insyde v: 1.10 
  date: 08/22/2017 
Battery:
  ID-1: BAT1 charge: 37.2 Wh (100.0%) condition: 37.2/48.9 Wh (76.1%) 
  volts: 16.6 min: 15.2 model: COMPAL PABAS0241231 type: Li-ion 
  serial: <filter> status: Full 
Memory:
  RAM: total: 15.52 GiB used: 6.19 GiB (39.9%) 
  Array-1: capacity: 32 GiB slots: 2 EC: None max-module-size: 16 GiB 
  note: est. 
  Device-1: ChannelA-DIMM0 size: 8 GiB speed: 2400 MT/s type: DDR4 
  detail: synchronous unbuffered (unregistered) bus-width: 64 bits 
  total: 64 bits manufacturer: Micron part-no: 8ATF1G64HZ-2G3B1 
  serial: <filter> 
  Device-2: ChannelB-DIMM0 size: 8 GiB speed: 2400 MT/s type: DDR4 
  detail: synchronous unbuffered (unregistered) bus-width: 64 bits 
  total: 64 bits manufacturer: Micron part-no: 8ATF1G64HZ-2G3B1 
  serial: <filter> 
CPU:
  Info: Quad Core model: Intel Core i7-7700HQ socket: U3E1 bits: 64 
  type: MT MCP arch: Kaby Lake family: 6 model-id: 9E (158) stepping: 9 
  microcode: EA cache: L1: 256 KiB L2: 6 MiB L3: 6 MiB bogomips: 44817 
  Speed: 3243 MHz min/max: 800/3800 MHz base/boost: 3400/8300 volts: 1.0 V 
  ext-clock: 100 MHz Core speeds (MHz): 1: 3243 2: 1742 3: 3431 4: 1225 
  5: 3684 6: 1601 7: 2639 8: 2526 
  Flags: 3dnowprefetch abm acpi adx aes aperfmperf apic arat arch_perfmon art 
  avx avx2 bmi1 bmi2 bts clflush clflushopt cmov constant_tsc cpuid 
  cpuid_fault cx16 cx8 de ds_cpl dtes64 dtherm dts epb ept ept_ad erms est 
  f16c flexpriority flush_l1d fma fpu fsgsbase fxsr ht hwp hwp_act_window 
  hwp_epp hwp_notify ibpb ibrs ida intel_pt invpcid invpcid_single lahf_lm lm 
  mca mce md_clear mmx monitor movbe mpx msr mtrr nonstop_tsc nopl nx pae pat 
  pbe pcid pclmulqdq pdcm pdpe1gb pebs pge pln pni popcnt pse pse36 pti pts 
  rdrand rdseed rdtscp rep_good sdbg sep smap smep ss ssbd sse sse2 sse4_1 
  sse4_2 ssse3 stibp syscall tm tm2 tpr_shadow tsc tsc_adjust 
  tsc_deadline_timer vme vmx vnmi vpid x2apic xgetbv1 xsave xsavec xsaveopt 
  xsaves xtopology xtpr 
  Vulnerabilities: Type: itlb_multihit status: KVM: VMX disabled 
  Type: l1tf 
  mitigation: PTE Inversion; VMX: conditional cache flushes, SMT vulnerable 
  Type: mds mitigation: Clear CPU buffers; SMT vulnerable 
  Type: meltdown mitigation: PTI 
  Type: spec_store_bypass 
  mitigation: Speculative Store Bypass disabled via prctl and seccomp 
  Type: spectre_v1 
  mitigation: usercopy/swapgs barriers and __user pointer sanitization 
  Type: spectre_v2 mitigation: Full generic retpoline, IBPB: conditional, 
  IBRS_FW, STIBP: conditional, RSB filling 
  Type: srbds mitigation: Microcode 
  Type: tsx_async_abort status: Not affected 
Graphics:
  Device-1: Intel HD Graphics 630 vendor: Acer Incorporated ALI driver: i915 
  v: kernel bus-ID: 00:02.0 chip-ID: 8086:591b class-ID: 0300 
  Device-2: NVIDIA GP106M [GeForce GTX 1060 Mobile] 
  vendor: Acer Incorporated ALI driver: nvidia v: 470.63.01 
  alternate: nouveau,nvidia_drm bus-ID: 01:00.0 chip-ID: 10de:1c20 
  class-ID: 0300 
  Device-3: Chicony HD WebCam type: USB driver: uvcvideo bus-ID: 1-9:3 
  chip-ID: 04f2:b5f7 class-ID: 0e02 
  Display: server: X.Org 1.20.13 compositor: kwin_x11 driver: 
  loaded: modesetting,nvidia unloaded: intel,nouveau alternate: fbdev,nv,vesa 
  display-ID: :0 screens: 1 
  Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.0x11.2") 
  s-diag: 582mm (22.9") 
  Monitor-1: eDP-1 res: 1920x1080 hz: 60 dpi: 142 size: 344x193mm (13.5x7.6") 
  diag: 394mm (15.5") 
  OpenGL: renderer: Mesa Intel HD Graphics 630 (KBL GT2) v: 4.6 Mesa 21.1.6 
  direct render: Yes 
Audio:
  Device-1: Intel CM238 HD Audio vendor: Acer Incorporated ALI 
  driver: snd_hda_intel v: kernel bus-ID: 00:1f.3 chip-ID: 8086:a171 
  class-ID: 0403 
  Device-2: NVIDIA GP106 High Definition Audio driver: snd_hda_intel v: kernel 
  bus-ID: 01:00.1 chip-ID: 10de:10f1 class-ID: 0403 
  Sound Server-1: ALSA v: k5.13.11-1-MANJARO running: yes 
  Sound Server-2: sndio v: N/A running: no 
  Sound Server-3: JACK v: 1.9.19 running: no 
  Sound Server-4: PulseAudio v: 15.0 running: yes 
  Sound Server-5: PipeWire v: 0.3.33 running: yes 
Network:
  Device-1: Qualcomm Atheros QCA6174 802.11ac Wireless Network Adapter 
  vendor: Lite-On driver: ath10k_pci v: kernel port: 4000 bus-ID: 02:00.0 
  chip-ID: 168c:003e class-ID: 0280 
  IF: wlp2s0 state: up mac: <filter> 
  IP v4: <filter> type: dynamic noprefixroute scope: global 
  broadcast: <filter> 
  IP v6: <filter> type: noprefixroute scope: link 
  Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet 
  vendor: Acer Incorporated ALI driver: r8169 v: kernel port: 3000 
  bus-ID: 03:00.1 chip-ID: 10ec:8168 class-ID: 0200 
  IF: enp3s0f1 state: down mac: <filter> 
  WAN IP: <filter> 
Bluetooth:
  Device-1: Lite-On type: USB driver: btusb v: 0.8 bus-ID: 1-7:2 
  chip-ID: 04ca:3016 class-ID: e001 
  Report: rfkill ID: hci0 rfk-id: 2 state: up address: see --recommends 
Logical:
  Message: No logical block device data found. 
RAID:
  Message: No RAID data found. 
Drives:
  Local Storage: total: 476.94 GiB used: 64.49 GiB (13.5%) 
  ID-1: /dev/sda maj-min: 8:0 vendor: Micron model: 1100 MTFDDAV512TBN 
  family: Micron Client SSDs size: 476.94 GiB block-size: physical: 512 B 
  logical: 512 B sata: 3.2 speed: 6.0 Gb/s type: SSD serial: <filter> 
  rev: A020 temp: 42 C scheme: GPT 
  SMART: yes state: enabled health: PASSED on: 91d 22h cycles: 4612 
  written: 12.3 TiB 
  Message: No optical or floppy data found. 
Partition:
  ID-1: / raw-size: 93.49 GiB size: 91.47 GiB (97.83%) used: 64.44 GiB (70.4%) 
  fs: ext4 block-size: 4096 B dev: /dev/sda5 maj-min: 8:5 label: N/A 
  uuid: a019a34f-6d74-4928-9cef-fbe5668e2e4a 
  ID-2: /boot/efi raw-size: 100 MiB size: 96 MiB (96.00%) 
  used: 49.9 MiB (52.0%) fs: vfat block-size: 512 B dev: /dev/sda1 
  maj-min: 8:1 label: ESP uuid: 5A99-0040 
Swap:
  Alert: No swap data was found. 
Unmounted:
  ID-1: /dev/sda2 maj-min: 8:2 size: 16 MiB fs: N/A label: N/A uuid: N/A 
  ID-2: /dev/sda3 maj-min: 8:3 size: 382.33 GiB fs: ntfs label: N/A 
  uuid: E0B60C97B60C6FF8 
  ID-3: /dev/sda4 maj-min: 8:4 size: 1024 MiB fs: ntfs label: Recovery 
  uuid: 6AA6A089A6A056FB 
USB:
  Hub-1: 1-0:1 info: Full speed (or root) Hub ports: 16 rev: 2.0 
  speed: 480 Mb/s chip-ID: 1d6b:0002 class-ID: 0900 
  Device-1: 1-7:2 info: Lite-On type: Bluetooth driver: btusb interfaces: 2 
  rev: 2.0 speed: 12 Mb/s power: 100mA chip-ID: 04ca:3016 class-ID: e001 
  Device-2: 1-9:3 info: Chicony HD WebCam type: Video driver: uvcvideo 
  interfaces: 2 rev: 2.0 speed: 480 Mb/s power: 500mA chip-ID: 04f2:b5f7 
  class-ID: 0e02 
  Hub-2: 2-0:1 info: Full speed (or root) Hub ports: 8 rev: 3.0 speed: 5 Gb/s 
  chip-ID: 1d6b:0003 class-ID: 0900 
Sensors:
  System Temperatures: cpu: 51.0 C mobo: 29.8 C 
  Fan Speeds (RPM): N/A 
Info:
  Processes: 288 Uptime: 2h 54m wakeups: 1 Init: systemd v: 248 
  tool: systemctl Compilers: gcc: 11.1.0 alt: 10 clang: 12.0.1 Packages: 1445 
  pacman: 1409 lib: 373 flatpak: 20 snap: 16 Shell: Zsh (sudo) v: 5.8 
  default: Bash v: 5.1.8 running-in: konsole inxi: 3.3.06 

Are the permissions set properly?
You can check with ls -l /path/to/dir of the file.
It should say something like -rwx-r-x-r-x at the begining of the line.
If it doesn’t have x anywhere then run sudo chmod +x /path/to/executable

Why VSCode neither in Ubuntu nor in Manjaro Gnome (which I had installed last week) did not give me this error and in Manjaro KDE it did?

Probably messed up the permissions copying the file between three different systems.

Hello @Dfdd :wink:

So my idea about this, is:

  1. bash executable assume that this file is a bash script and therefore through this error.
  2. bash -c executable is the same as bash ./executable or ./executable. There it assumes it is a binary, if not, then it interprets the script (sure Shebang must be set: #!/usr/bin/env bash)

No idea why it works on Ubuntu and Manjaro Gnome, but that behaves normal for me.

Yes, I check out that and permissions are fine

Oh my mistake … the command that works is:

bash -c ./executable

I have to correct the post.

What doesn’t work is:

bash -c executable

and

bash ./executable

well then just run:

./executable

Why would you need bash, since you are already on the bash shell?

What file is it?

file executable

Yes, this works. But the problem here is that apparently what visual studio code does behind the scenes to execute the code in an external console is to call the command

bash executable

or

bash ./executable

and what I want is the external terminal to appear automatically as Visual Studio Code always has done and not having to invoke it myself

What really breaks my mind here is that in Ubuntu and even in the Gnome version of Manjaro I simply wrote the command and it did not give me an error and now with Manjaro KDE it happens to me that I have to write it that way and I don’t know why . The worst of all is that it even hinders the operation of the visual studio code for external terminals

Which Terminal and Shell?

echo -e "Terminal: $TERM\nShell: $SHELL"

I have this:

Terminal: xterm-256color
Shell: /bin/zsh

I tested it myself

  1. :white_check_mark: bash script.sh
  2. :white_check_mark: bash -c script.sh (if chmod +x)
cp /usr/bin/ls ~/bin && cd ~/bin
  1. :negative_squared_cross_mark: bash ls
  2. :white_check_mark: bash -c ls

Well yes confirmed…

Maybe a workaround would be an alias:

alias bash="bash -c"

at ~/.bashrc.

source ~/.bashrc

Then you can run:

bash executable
1 Like

Not being able to execute either a script or a binary from the folder containing the file (and not in the path) is by design and cannot be changed.

As a security measure *nix-like systems only allows execution by name if the executable is in the path.

If you want to execute something within the current folder it must be prepended with the path to the executable.

This can be the full path or using a dot which designates current folder.

Yes, this works but it is a temporary solution since doing this I can no longer execute the .sh files

I read about it a few hours ago … but we are losing the central point of this thread which is to know why the invocation of the external terminal by VSCode drops that error in Manjaro KDE but it did not drop it in Manjaro Gnome or in Ubuntu… and above all, how do I solve this?

It appears to be an issue with VSCode - not the system in question.

I can think of one theory - but I don’t know if it hold - it contains the following elements

  1. Microsoft has always executed scripts and exe from current folder
  2. Powershell follow *nix tradition - also on Windows - where you must include the path eg. .\program.exe
  3. When Microsoft implemented WSL it was by using Ubuntu
  4. Ubuntu is using Gnome as the default DE
  5. VSCode is a relatively new code editor developed by Microsoft

I see Ubuntu, Gnome, VSCode as the common denominators - where KDE falls outside - which is why the correct message is thrown.

Good question - How about creating an issue with the VSCode developers?

1 Like

ok, thank you very much for your attention and dedicating a little of your time. Looks like I’ll have to put this as a flaw in VSCode

Thanks for the help anyway

Well, I managed to solve this problem. The key is that I set the external console to call “bash” and bash is not an external console as such. In Manjaro KDE the external console by default is “konsole” and then that was the one I sent to execute.
That is, in the visual studio code settings go to “Features > Terminal” and in the option called “External: Linux Exec” you change whatever you have written for the name of the external console. In the case of Manjaro KDE the external console is called “konsole” and that solves the problem

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.