Windows 上的 Ubuntu 上的 Bash 无法启动
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44049070/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bash on Ubuntu on Windows not starting
提问by oblong
So, I've been using the new(ish) Bash on Ubuntu on Windows (WSL) for a while now and all has been top-notch, until yesterday.
因此,我一直在 Windows (WSL) 上的 Ubuntu 上使用新的(ish)Bash,直到昨天,一切都是一流的。
I git-pushed from Bash by accident, so it asked me for my repo-destination account details like normal. I decided to ignore this, terminate Bash and try to just use powershell instead (can't ever remember passwords!). Terminating Bash however caused the shell to freeze. I forced closed and restarted my comp (I've had to force close and restart several times before for various reasons and everything was fine).
我不小心从 Bash 推送了 git-push,所以它像往常一样询问我的 repo-destination 帐户详细信息。我决定忽略这一点,终止 Bash 并尝试只使用 powershell(永远记不住密码!)。然而,终止 Bash 会导致外壳冻结。我强行关闭并重新启动了我的组合(由于各种原因,我不得不多次强行关闭并重新启动,一切都很好)。
After boot up, I just tried to check if Bash was working again, but it wasn't. It just failed to start with no error message. For example:
启动后,我只是尝试检查 Bash 是否再次工作,但事实并非如此。它只是无法启动,没有错误消息。例如:
PS C:\WINDOWS\system32> bash
PS C:\WINDOWS\system32>
Has anyone else had a similar situation/knows how to help?
有没有其他人有类似的情况/知道如何提供帮助?
EDIT: Only solved through reinstalling bash, using
编辑:只能通过重新安装 bash 解决,使用
lxrun /uninstall /full
then
然后
lxrun /install
回答by Dave S
Came here with a similar issue, but a different solution, so I'll post in case it helps anyone else.
来到这里遇到类似的问题,但解决方案不同,所以我会发布以防它对其他人有所帮助。
The difference in my situation was that, when running bash
through Command Prompt, it complained about Legacy Mode being enabled.
我的情况的不同之处在于,在bash
通过命令提示符运行时,它抱怨启用了旧模式。
- Open a regular command prompt (
win+r
thencmd
) - Right-click the title bar and select
Properties
- Deselect "Use legacy console (requires restart)"
- 打开常规命令提示符(
win+r
thencmd
) - 右键单击标题栏并选择
Properties
- 取消选择“使用旧控制台(需要重新启动)”
Now it should work either by launching the standalone app, or typing bash
into a regular cmd
window after restarting Command Prompt.
现在它应该通过启动独立应用程序或在重新启动命令提示符后在bash
常规cmd
窗口中输入来工作。
This and other causes can be found in this Github issue.
这个和其他原因可以在这个 Github 问题中找到。
回答by Robert Yi
The solutions listed also did not work for me. I found a solution here.
列出的解决方案对我也不起作用。我在这里找到了解决方案。
Essentially, navigate to Control Panel > System > Advanced System Settings > Advanced > Settings > Advanced > Virtual memory, Change ...
, and set a Custom size for the paging file size: 800 min and 1024 max. Restarted, and the command prompt came back.
基本上,导航到Control Panel > System > Advanced System Settings > Advanced > Settings > Advanced > Virtual memory, Change ...
,并为分页文件大小设置自定义大小:800 分钟和 1024 最大。重新启动,命令提示符又回来了。
回答by Viacheslav Shchupak
Linux Distribution should be installed additionally to Windows Subsystem for Linux. See Install WSL on Windows 10or Install WSL on Windows Serverfor detailed steps and explanations. In case mentioned manuals are moved or not available I'll put below main steps for Windows 10 that helped me:
Linux 发行版应额外安装到 Windows 子系统 Linux 中。有关详细步骤和说明,请参阅在 Windows 10 上安装 WSL或在 Windows Server 上安装 WSL。如果提到的手册被移动或不可用,我将在下面列出对我有帮助的 Windows 10 的主要步骤:
- Open PowerShell as Administrator and run
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
- Restart computer if prompted.
- Open PowerShell and run
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile Ubuntu.appx -UseBasicParsing
- Execute the downloaded
Ubuntu.appx
. - Enjoy running bash on Windows again.
- 以管理员身份打开 PowerShell 并运行
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
- 如果出现提示,请重新启动计算机。
- 打开PowerShell并运行
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile Ubuntu.appx -UseBasicParsing
- 执行下载的
Ubuntu.appx
. - 再次享受在 Windows 上运行 bash 的乐趣。
回答by BrokenShoebox
I've had similar issues. The solution for me was to disable fast startupin powers settings.
我有过类似的问题。我的解决方案是在电源设置中禁用快速启动。
回答by Wolfpack'08
Section i: other error messages.
第 i 部分:其他错误消息。
This error is closely followedby a second error, code 0x80070057 (see section 2)!
This error also manifestsas "Windows Subsystem for Linux has no installed distributions. Distributions can be installed by visiting the Microsoft Store: https://aka.ms/wslstore" by typing
Bash
at cmd/powershell. Use Section 1 then Section 2.
此错误紧随其后的是第二个错误,代码0x80070057(请参阅第 2 节)!
此错误还表现为“适用于 Linux 的 Windows 子系统没有安装发行版。可以通过访问 Microsoft Store:https: //aka.ms/wslstore来安装发行版”,
Bash
并在 cmd/powershell 中键入。使用第 1 节,然后使用第 2 节。
Section ii: verify your installation and restart.
第 ii 节:验证您的安装并重新启动。
Be surethat WSL (Windows Subsystem Linux) is checked/installedand your computer had a proper restart: {?START}→ type "features
" (ensure "Turn Windows features on or off" is selected). → {ENTER}. → Turn Windows Subsystem for Linux on. → Press OK. → Restart your computer immediately after the installation has finished.
确保检查/安装了WSL(Windows 子系统 Linux)并且您的计算机已正确重启:{?START}→ 键入“ features
”(确保选择“打开或关闭 Windows 功能”)。→ {ENTER}。→ 打开适用于 Linux 的 Windows 子系统。→ 按确定。→ 安装完成后立即重新启动计算机。
Section 1a: Install Linux [via the Microsoft Store].
第 1a 部分:[通过 Microsoft Store] 安装 Linux。
- Press {?START}on your keyboard.
- Type "
store
" ensure "Microsoft Store" is selected. → {ENTER}}. - {SHIFT}-{TAB}twice (highlight search). → {ENTER}.
- type "
subsystem
". → {ENTER}. - Select your flavor of Linux (i.e., "Ubuntu LTS 18.04") and click "Install".
- {?START}. -> Type "
ubuntu
" (ensure Ubuntu App is selected). → {ENTER}.
- 按下{?START}键盘。
- 输入“
store
”确保选择了“Microsoft Store”。→ {ENTER}}。 - {SHIFT}-{TAB}两次(突出显示搜索)。→ {ENTER}。
- 输入“
subsystem
”。→ {ENTER}。 - 选择您的 Linux 风格(即“Ubuntu LTS 18.04”)并单击“安装”。
- {?START}. -> 输入“
ubuntu
”(确保选择了 Ubuntu 应用程序)。→ {ENTER}。
Section 1b: Side-load Linux.
第 1b 节:旁加载 Linux。
*This is a placeholder--you can manually install WLS--https://docs.microsoft.com/en-us/windows/wsl/install-manual. I have not done this, yet. If you have done this, please add instructions by editing my answer; otherwise, I will post this section after performing this operation myself.
*这是一个占位符——您可以手动安装 WLS—— https://docs.microsoft.com/en-us/windows/wsl/install-manual 。我还没有这样做。如果您已经这样做了,请通过编辑我的答案来添加说明;否则,我将在自己执行此操作后发布此部分。
Section 2: if launching Ubuntu throws 'WslRegisterDistribution failed with error: 0x80070057'**
第 2 部分:如果启动 Ubuntu 抛出“WslRegisterDistribution failed with error: 0x80070057”**
After installing a linux flavor:
安装 linux 版本后:
- {?START}→ type "
features
" (ensure "Turn Windows features on or off" is selected). → {ENTER}. - Turn Windows Subsystem for Linux off. → Press OK.
- Turn Windows Subsystem for Linux on.
- Restart your computer.
- {?START}. → type "
ubuntu
" (ensure "Ubuntu App" is selected). → {ENTER}
- {?START}→ 输入“
features
”(确保选择“打开或关闭 Windows 功能”)。→ {ENTER}。 - 关闭适用于 Linux 的 Windows 子系统。→ 按确定。
- 打开适用于 Linux 的 Windows 子系统。
- 重启你的电脑。
- {?START}. → 输入“
ubuntu
”(确保选择了“Ubuntu App”)。→{ENTER}
**This is the most-accepted solution for this issue is the last answer on page two at Microsoft Answers.
**这是针对此问题最广为接受的解决方案,是Microsoft Answers上第二页的最后一个答案。
回答by Neel Ponkia
I had the same issue the following fix worked for me:
我遇到了同样的问题,以下修复对我有用:
Fix:
使固定:
- restart by clicking shift + restart button.
- it will load recovery options, just click on continue to windows.
- once pc starts open the terminal by start search for ubuntu click enter
- once terminal gets open it might show cursor blinking and does nothing.
- just press cntrl+c or cntrl+z and you will have problem solved.
- 通过单击 shift + 重新启动按钮重新启动。
- 它将加载恢复选项,只需单击继续 Windows。
- 一旦电脑启动通过开始搜索ubuntu打开终端点击回车
- 一旦终端打开,它可能会显示光标闪烁并且什么也不做。
- 只需按 cntrl+c 或 cntrl+z 即可解决问题。
回答by Calvin Gomes
Do a FULL REBOOT. That worked for me. Windows 10 fast boots system to save memory. TO do a Full Reboot Hold Shiftand Click on Restart/Shutdown.
做一个完全重启。那对我有用。Windows 10 快速启动系统以节省内存。执行完全重启按住Shift并单击重启/关机。
回答by user46083
Right after Windows Updates KBB4471324 and a reboot, Bash wouldn't launch. No messages.
在 Windows 更新 KBB4471324 并重新启动后,Bash 不会启动。没有消息。
In event viewer I saw messages about
在事件查看器中,我看到了关于
The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID
特定于应用程序的权限设置不会为具有 CLSID 的 COM 服务器应用程序授予本地激活权限
I didn't bother trying to figure out if the SID, CLSID and APPID were associated with bash.
我没有费心去弄清楚 SID、CLSID 和 APPID 是否与 bash 相关联。
I launched Bash as administrator, which worked, and then bash as a normal user, which worked. It seems to be fine, now.
我以管理员身份启动了 Bash,它起作用了,然后以普通用户的身份启动了 bash,它起作用了。现在好像没事了。
回答by Love and peace - Joe Codeswell
See my comment to original poster. Your fix did not work for me. here is the PowerShell [as admin] listing: Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.
请参阅我对原始海报的评论。你的修复对我不起作用。这是 PowerShell [作为管理员] 列表:Windows PowerShell 版权所有 (C) Microsoft Corporation。版权所有。
PS C:\WINDOWS\system32> lxrun /uninstall /full
Warning: lxrun.exe is only used to configure the legacy Windows Subsystem for Linux distribution.
Distributions can be installed by visiting the Microsoft Store:
https://aka.ms/wslstore
This will uninstall Ubuntu on Windows.
This will remove the Ubuntu environment as well as any modifications, new applications, and user data.
Type "y" to continue: y
Uninstalling...
Error: 0x80070002
PS C:\WINDOWS\system32>
I went to https://aka.ms/wslstore
- chose ubuntu
- it downloaded
- clicked 'pin to start'
- clicked 'Launch'
- 选择了 ubuntu
- 它下载了
- 点击“固定开始”
- 点击“启动”
Ubuntu [window]:
Ubuntu [窗口]:
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: joe
Enter new UNIX password: joepw202
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: joe
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
joe@joethinks:~$
Please note: BUMMER!None of my shortcuts or installs were moved over from my last version. Here i am running BASH from vscode:
请注意:BUMMER!我的快捷方式或安装都没有从我的上一个版本中移出。在这里,我从 vscode 运行 BASH:
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
joe@joethinks:/mnt/c/1d/TrinitySundayMusicPj$ cdtsm
cdtsm: command not found
joe@joethinks:/mnt/c/1d/TrinitySundayMusicPj$ cd trinitySundayMusic
joe@joethinks:/mnt/c/1d/TrinitySundayMusicPj/trinitySundayMusic$ node wizard.js
The program 'node' is currently not installed. You can install it by typing:
sudo apt install nodejs-legacy
joe@joethinks:/mnt/c/1d/TrinitySundayMusicPj/trinitySundayMusic$
At least it works.
至少它有效。