标签: windows-subsystem-for-linux

如何在 React 应用程序、Docker 内部、WSL 内部处理热重载?

首先,这是我一直在谈论的存储库:Github

在我的带有 Docker 的 Macbook 上,这工作得很好。但我一直在尝试使用WLS(Windows内的Ubuntu)。我已经跟进了本教程,了解如何在 WLS 中处理 Docker(以及如何处理卷)

它有效,我更改了主机(Windows)中的代码,实际上它在容器(Linux 中的 Docker)内部发生了变化,但由于某种原因,应用程序不会刷新

我正在使用两个应用程序,一个是 React 应用程序(使用react-scripts),另一个是 Express 应用程序(使用nodemon)。两者都不会在更改时重新加载。

可能出什么问题了?

express docker reactjs windows-subsystem-for-linux

3
推荐指数
1
解决办法
1635
查看次数

在 WSL 上从 Bash 打开 Sublime Text

我已经做好了

别名 subl='"/mnt/c/Program Files/Sublime Text 3/subl.exe"'

但是,执行 subl test.txt 现在将在 C:/System32/test.txt 中打开 Sublime text,该文本不存在,因此我无法保存它。我也不想将某些内容保存到 System32。如何更改它以便打开我的实际文件?

另外,如果我执行 subl ~/test.txt 那么它会尝试打开C:\home\<myname>\test.

bash window sublimetext3 windows-subsystem-for-linux

3
推荐指数
1
解决办法
5069
查看次数

无法连接到 wsl 2 上 debian buster 上的 Docker 守护进程

我正在尝试在 Windows Subsystem for Linux (WSL) 2(在 Windows Home build 19033.1 上运行)上安装 docker。我按照https://learn.microsoft.com/en-us/windows/wsl/wsl2-install上的说明安装了 wsl2 ,并从 Windows 应用商店安装了 debian,即 debian 10 (buster)。它正在 wsl 2 上运行,如下所示:

wsl -l -v
名称状态版本
* Debian 运行 2

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL=" https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

我按照https://linuxconfig.org/how-to-install-docker-on-debian-10-buster-linux上的说明安装 docker:

sudo apt install docker.io
sudo docker run hello-world
docker:无法连接到位于 unix:///var/run/docker.sock 的 Docker 守护进程。docker 守护进程是否正在运行?

查看 docker 是否正在运行:

sudo service docker status
[FAIL] Docker 未运行...失败! …

docker windows-subsystem-for-linux debian-buster wsl-2

3
推荐指数
1
解决办法
2756
查看次数

在 Window 和 WSL 之间共享 docker 凭据

环境

  • Windows 版本和内部版本 2004 版(操作系统内部版本 19037.1)
  • Docker Edge 版本 2.1.6.1
  • WSL 2 上的 Ubuntu 18.04

当前设置和状态:

  • docker安装在windows上
  • 为 docker、docker-compose、docker-credential-desktop 等创建了别名...

运行docker builddocker psdocker pull等命令docker images都可以正常工作。现在我想推送一个图像,所以我当然必须先登录。

问题:登录 docker hub。

  • docker login我在 WSL 终端中运行
  • 我输入了我的用户名和密码
  • 我收到以下错误
Error saving credentials: error storing credentials - err: exec: "docker-credential-desktop": executable file not found in %PATH
%, out: ``
Run Code Online (Sandbox Code Playgroud)

到目前为止我尝试过的

docker login来自 powershell 工作正常。/mnt/c/Users/<winusername>/.docker所以我在和之间创建了一个符号链接/home/<wslusername>/.docker。等效的方法适用于.aws,但.docker它无法共享甚至确认凭据,因此它再次要求输入用户和密码,并抛出与上面相同的错误。

authentication credentials docker windows-subsystem-for-linux

3
推荐指数
1
解决办法
1万
查看次数

在 WSL 中运行 genhtml

我一直在尝试使用 WSL 为我的 flutter 项目的代码覆盖率生成 html 报告,但是当我运行时会发生这种情况genhtml coverage/lcov.info -o coverage/html

Reading data file coverage/lcov.info
Resolved relative source file path "lib\blocs\bloc1\bloc1.dart" with CWD to "/mnt/c/Users/User/flutter_project/lib\blocs\bloc1\bloc1.dart".
Found 284 entries.
Found common filename prefix "/mnt/c/Users/User/flutter_project"
Writing .css and .png files.
Generating output.
Processing file flutter_project/lib\otherDir\other_file.dart
genhtml: ERROR: cannot read /mnt/c/Users/User/flutter_project/lib\otherDir\other_file.dart
Run Code Online (Sandbox Code Playgroud)

我可以理解这可能与路径有关,但我不确定如何修复它。有小费吗?

lcov flutter windows-subsystem-for-linux

3
推荐指数
1
解决办法
1823
查看次数

尝试通过 ubuntu WSL 终端在 Rails 上安装 ruby​​ 时出现多个错误

我目前通过 Linux 的 Windows 子系统使用全新安装的 ubuntu 18.04.2 LTS。我使用安装了红宝石

sudo apt-get install ruby2.5-dev
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用安装导轨

gem install rails -v 5.2.3
Run Code Online (Sandbox Code Playgroud)

这给了我一个Gem::FilePermissionError错误,可以使用 sudo 修复,但网上多个消息来源都说不要使用 sudo 安装 gem,尽管它们似乎都在使用 MacOS。

当我忽略它们并尝试使用 sudo 安装时,我得到以下信息:

    Building native extensions. This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.5.0/gems/nokogiri-1.10.7/ext/nokogiri
/usr/bin/ruby2.5 -r ./siteconf20200123-2772-1f46u2w.rb extconf.rb
checking if the C compiler accepts ... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries …
Run Code Online (Sandbox Code Playgroud)

ruby rubygems ruby-on-rails mkmf windows-subsystem-for-linux

3
推荐指数
1
解决办法
1020
查看次数

使用 WSL 时检查是否在 Windows 中运行的 Shell 脚本?

我正在尝试向我的 .zshrc 文件添加一个条件,该条件将初始化一些配置内容,而我只想在适用于 Linux 的 Windows 子系统中进行这些配置。我尝试过这个但没有运气:

if [ "$('cmd.exe /c "systeminfo" | grep "^OS Name"')" =~ "Windows" ]; then
        echo "windows baby!"
fi
Run Code Online (Sandbox Code Playgroud)

这使:

no such file or directory: cmd.exe /c "systeminfo" | grep "^OS Name"
Run Code Online (Sandbox Code Playgroud)

...但是如果我直接在 shell 中键入该命令,该命令就会起作用。有任何想法吗?

windows shell zsh windows-subsystem-for-linux

3
推荐指数
1
解决办法
1816
查看次数

如何在当前 powershell 目录中启动 WSL 终端?

我可以打开 powershell 并输入

> Ubuntu 
Run Code Online (Sandbox Code Playgroud)

在 Windows 10 上打开 WSL ubuntu shell。这将始终将我带到 WSL 主目录。我该如何在 powershell 当前所在的同一位置打开终端?

供参考。我需要这个来为 Windows 资源管理器创建右键单击“在此处打开终端”类型的注册表项。

powershell windows-subsystem-for-linux

3
推荐指数
2
解决办法
2万
查看次数

在 Linux 主机上运行的 Windows 10 来宾 VM 中运行 WSL2

我有一个 Windows VM,用于代替真实的 WIndows 机器进行测试。我想在该虚拟机内启用 WSL2。

到目前为止我已经:

  • 将 Windows 升级到 v2004。
  • 通过在 kvm-intel 内核模块中启用嵌套虚拟化options kvm-intel nested=1
  • 确保sudo cat /sys/module/kvm_intel/parameters/nested输出“Y”。
  • <cpu model='host-passthrough'>在 virt-manager 的 xml 配置中设置。

还是没有骰子。一旦我根据 WSL2 的要求启用“虚拟机平台”功能,我的虚拟机就会在启动时开始冻结。

有人成功地做到了这一点吗?

qemu windows-subsystem-for-linux

3
推荐指数
1
解决办法
5762
查看次数

如何在 Linux (Debian 10) 的 Windows 子系统上开发 Flutter Web 应用程序

我想在 Linux (Debian 10) 的 Windows 子系统上开发 Flutter Web 应用程序。我遵循了这个指示。https://flutter.dev/docs/get-started/codelab-web

\n\n
flutter channel beta\nflutter upgrade\nflutter config --enable-web\n
Run Code Online (Sandbox Code Playgroud)\n\n

首先,我在终端中输入这些命令,所有命令都运行良好。

\n\n

其次,我尝试了flutter doctor命令,这就是结果。

\n\n
Downloading android-arm-release/linux-x64 tools...                  2.1s\nDownloading android-arm64-profile/linux-x64 tools...                1.8s\nDownloading android-arm64-release/linux-x64 tools...                1.6s\nDownloading android-x64-profile/linux-x64 tools...                  1.6s\nDownloading android-x64-release/linux-x64 tools...                  1.5s\nDoctor summary (to see all details, run flutter doctor -v):\n[\xe2\x9c\x93] Flutter (Channel beta, 1.18.0-11.1.pre, on Linux, locale en_US.UTF-8)\n[\xe2\x9c\x97] Android toolchain - develop for Android devices\n    \xe2\x9c\x97 Unable to locate Android SDK.\n      Install Android Studio from: https://developer.android.com/studio/index.html\n      On first launch …
Run Code Online (Sandbox Code Playgroud)

google-chrome flutter windows-subsystem-for-linux

3
推荐指数
1
解决办法
4946
查看次数