Strange cmder behavior


(Victor) #1

I just started with Go and generally I am new in programming.
I noticed a strange behavior of cmder bash session when I run a compiled to exe Go program.
I put the program into the Windows folder.
It just calculate an md5sum of a text. The command line argument is the text.
When I run the program by cmd or cmder/cmd session it runs as expected.
If I run it by cmder/bash session the system tells me that there is no such file or directory. It takes the argument as a path.
Why is that? I am asking because it’s more convenient for me to use bash syntax.


(Holloway) #2

Sounds like a build architecture problem. As far as I understand:

  1. the compiled binary is for windows/amd64 (I’m assuming you’re operating on Windows)
  2. cmder/bash should be operating in unix architecture, which also means there are a lot of architecture to choose from. (Suggest linux/amd64).
  3. cmd is operating on Windows architecture, therefore, the existing binary works.

Try cross-compile into linux/amd64 and use cmder/bash to find the new binary. You need to export GOARCH=linux/amd64.

I previously wrote a guide here: https://sites.google.com/view/chewkeanho/guides/go/build. However, I did no have the command line for Windows to cross-compile. You might need to explore a bit.

Keywords: cross-compile, GOARCH


NOTE: I may be wrong since there is limited information available from your question.


(Norbert Melzer) #3

I’m not sure if I understand you correctly… What do you mean by “I put the program into the Windows folder”? Are you talking about C:\Windows here? Please remove it there, thats the OS’ space and shouldn’t be touched by you.

From what you describe otherwise, it seems to be a discrepancy in PATH between both environments. Usually bash will inherit the PATH of the parent environment (windows system in your case), at least if you are using a bash from a POSIX compatibility layer as cygwin or “git for windows”. You might have overwritten it in the .bashrc then though.

If though you use the WSL-bash then it has its own environment and does not inherit from windows at all, as it is a “real” linux and wouldn’t be able to run windows binaries anyway.


(Huseyin Ozdemir) #4

These works is more simple on mac or linux. Did you try these platforms?


(Norbert Melzer) #5

Even though I’d always prefer Linux over windows or macOS, proposing to use a different operating system is not the solution to the problem at hand.

In fact the problem seems to be that the user doesn’t understand how different tools on their computer work together. This problem can happen on every operating system and is not unique to windows.


(Holloway) #6

let’s wait for OP to supply more information. Otherwise, it’s hard to tell where went wrong.


(Victor) #7

I’m not quite sure what information to provide. I’m using Windows 10 x64 right now. I am planing to install a Linux system but on a separate hard disk. Which I have to buy. I prefer Linux but have to work on Windows.

I didn’t touch .bashrc or any other configuration. I installed WLS yesterday and I could use that eventually. As soon as I know how to access the computer’s folders and the files.

Quick research gives me that C drive is located in /mnt . So obvious that I even didn’t think about it :smiley:


(Holloway) #8

Noted, keep in mind that Go program requires you to cross-compile to the deployment OS.

As far as I understand, WLS is a different system. You need to compile to linux/amd64 and give it a try.


(Victor) #9

I will remember that. Thank you.


(Eric Lindblad) #10

running 64-bit

probably as a new coder you could get an old desktop and install a GNU Linux distribution on it

early WSL missed at least one Linux system call (implemented in Creator’s Update)

N. Melzer mentioned ‘git for windows’

old link here for a 32-bit install of ‘git for windows’ on XP


(Eric Lindblad) #11

a couple of tests of early WSL (Anniversary Update)

respectively from Mar. and Apr. of 2017

p9p (plan9port), xs (extensible shell written in C++)

acme functioned properly using VcXsrv under WSL