Closed lord-executor closed 8 years ago
Are you by any chance running the 32-bit cmd or 32-bit powershell? If you are, those programs will show up in C:\Windows\Sysnative iirc. Any 32-bit program (using WoW64) sees the WoW64 version of system32 instead of the real (sysnative) one.
Interesting idea and thank you very much for the tip. I was running 32-bit cmd.exe but 64-bit PowerShell with the same results. I now also tested 64-bit cmd.exe (from "C:\Windows\SysWOW64\cmd.exe") but it still didn't find it where it is supposed to be.
Before now I had never heard of "C:\Windows\Sysnative" - probably because it doesn't show up anywhere, but I can navigate there with all my shells and the commands are there and can be executed. Which is great, but also massively confusing.
I'll be reading up on Sysnative now, but aren't those commands supposed to be in the PATH by default?
Hmm... maybe I got that wrong since apparently the cmd.exe in SysWOW64 is the 32-bit version while the one in System32 is the 64-bit version (really? I mean.... really?).
I think the problem is/was that my preferred launcher app (Launchy) is 32-bit and therefore launches the 32-bit version of cmd.exe from System32 (where the 32-bit version is if a 32-bit application is asking)...
I'll do some more testing and will very likely be closing this issue with a detailed explanation and some links for the next poor soul that gets confused by Windows and it's approach to 32/64 bit.
It's purely for compatibility reasons. Windows x64 has always had its 32-bit support set up so that it can run old 32-bit programs so that they only see a 32-bit version of Windows.
@fpqc: Thanks again for pointing me towards the whole 32/64 bit issue. I probably would have wasted quite a bit of time on that without your help.
I understand that this is for compatibility reasons, as a developer I just fundamentally disagree with some of the decisions behind it because it puts the burden on people trying to understand the current system instead of those that have been refusing to deal with their self-inflicted technical debt in their applications since the mid 90's when all of this fancy new 64-bit stuff first popped up.
For the next people running into this problem.
If you, like me, can't find bash
and lxrun
in your PATH or anywhere else with your command prompt, then try executing
echo %PROCESSOR_ARCHITECTURE%
If this gives you 'x86' (aka 32-bit), then you have the same problem that I have that you're just running the wrong version of cmd.exe
Ubuntu on Windows requires a 64-bit version of Windows, so I am assuming you are working on a 64-bit Windows. Here, the 64-bit system binaries are located in "C:\Windows\System32" while the 32-bit versions (of those binaries that have a 32-bit equivalent) are located in "C:\Windows\SysWOW64". "WOW64" stands for "Windows [32-bit] on Windows 64[-bit] which is the technology that allows you to run 32-bit applications on a 64-bit OS in the first place. If that seems mildly confusing, then that is probably because it is.
When you run a 32-bit application, then some "magic" mapping behind the scenes means that for this 32-bit application, the System32 directory is mapped to the SysWOW64 directory which means that in this context, 32-bit applications are now located in "C:\Windows\System32". If this 32-bit application is your command prompt, then it can't find bash
and lxrun
because they don't have a 32-bit version and are therefore not in the SysWOW64 directory - which is mapped to System32 - which is the directory in your PATH. So, if you take your (64-bit) File Explorer and go to "C:\Windows\System32" and run "cmd.exe" you get the 64-bit version, but if you launch "C:\Windows\System32\cmd.exe" from a 32-bit application, then you get 32-bit cmd.exe.
And for completeness: If you do need to access 64-bit system files like bash
and lxrun
from a 32-bit application, there is a virtual "C:\Windows\Sysnative" directory which is only accessible from 32-bit programs that contains the original 64-bit System32 files.
http://www.samlogic.net/articles/32-64-bit-windows-folder-x86-syswow64.htm http://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm http://ss64.com/nt/syntax-64bit.html
Just to second @getu-lar, here's what Canonical explains about lxrun
:
You need to have a system running today’s 64-bit build of Windows 10
https://insights.ubuntu.com/2016/04/14/howto-ubuntu-on-windows-2/
WOW64 subsystem emulates 32-bit environment, so everything (filesystem I/O, registry I/O is redirected to its 32-bit locations), unless you specify the Sysnative virtual directory in path, as explained here: https://msdn.microsoft.com/en-us/library/windows/desktop/aa384274(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx
So that's why you can't see 64-bit lxrun from 32-bit Command Prompt.
Quite offtopic, but could somebody please confirm that MSFT's lxrun is the same as the one explained here: https://www.usenix.org/legacy/publications/library/proceedings/usenix98/freenix/record_html/lxrun-1.html
Lxrun is an emulator that allows the execution of Intel Linux binaries on Intel UNIX® platforms.
@gudenuff I seriously doubt that there is any relationship between this lxrun and that other one. The only reason I would hesitate at all to say that is that lxrun is such a silly name for what the program actually does. (I would imagine lxrun would do like bash.exe -c and the current lxrun should be called like "lxadmin", but the names are what they are and will probably stick)
FYI: @getu-lar === @lord-executor
@getu-lar Uhh, the first AMD64 stuff was released in like.. 2004-2005? WinXP for AMD64 came out in late 2004 iirc. Linux did not move 32-bit x86 to legacy until like 2011. WoW64 was a solution introduced in 2004 in XP 64bit, and this is probably the first time it has ever even been noticeable to you, so please relax.
Also, interestingly enough, I watched a talk by one of the metasploit maintainers, and he said that it's actually quite a bit harder breaking out of a sandbox running in WoW64 than native x64 code, so make sure you run the 32bit versions of your browser!!
Side note, for those who may run into the same problem: I was unable to run lxrun unless in the windows\system32 directory in the command prompt. I believe this has something to do with being logged in via a domain login instead of a local user account. (Different path vars)
I run into the same problem, I was calling "bash" and "lxrun" from powershell and somehow my 7zip automated installed called the 32bit powershell instead of the 64bit one, this was the solution: https://stackoverflow.com/questions/19055924/how-to-launch-64-bit-powershell-from-32-bit-cmd-exe
I have the same issue but when I execute: "echo %PROCESSOR_ARCHITECTURE%" The system responds with "AMD64", but even now when I type bash in powershell or cmd I get this error: Windows Subsystem for Linux has no installed distributions. Distributions can be installed by visiting the Microsoft Store: https://aka.ms/wslstore
And when I try to run it as an administrator from start, it does not respond.
I also couldn't find any useful info on the provided Microsoft web (https://aka.ms/wslstore)?
Can anybody chip in?
@FarzadMohaddes your issue seems to be somewhat separate from the original issue posted here.
I'd recommend that you go to the WSL Microsoft store page and install a Linux distribution. Ubuntu
is a great pick for your first distro. Once that's installed run the app and go through the first setup process then you'll be able to run WSL. For more info check our docs - Install WSL.
If you run into any further issues please open up a new issue and we'll help you out there.
I have through the store installed Kali, and also have WSL. I have bash (and starting it successfully, but NO lxrun :-( Missing file. My cmd echo is AMD64. The file itself is missing from /System32 PLS advice where to get that stupid exe file?
PS: Win 1909 [10.0.18363.592]
Found the answer here: Google translated it as: .... if you are running Windows 10 Spring 2018 Update (or higher) that lxrun.ex does not ship with...
A brief description I realize that this might have nothing to do with BashOnWindows, but I couldn't find anything on this topic anywhere through Google/Bing. My Bash on Windows is actually running just fine, what is very confusing is that I cannot run bash.exe or LxRun.exe from the Windows command prompt (cmd.exe) or the PowerShell.
I can see both files in the File Explorer under C:\Windows\System32 and I can start the bash.exe from there, but when I try to start bash.exe or LxRun.exe from the command prompt I just can't. I cannot list the files (with "dir" in cmd.exe or "ls -al" in PowerShell) and if I try to execute them directly, it tells me that those files don't exist. Everything else in System32 (and anywhere else for that matter) seems to behave as expected.
'C:\Windows\System32\bash.exe' is not recognized as an internal or external command, operable program or batch file.
'C:\Windows\System32\LxRun.exe' is not recognized as an internal or external command, operable program or batch file.