Github 操作:没有这样的文件或目录错误
Github Actions: No such file or Directory error
背景
我正在尝试使用 Windows 和 Bakeware 进行 Github 操作,因为我正在尝试使用它创建一个版本。
但是,我在创建文件夹时遇到了意外问题。
代码
以下是 github 操作,是该问题的最小工作示例。
基本上,所有步骤都有效,除了创建单个文件夹:
name: build
env:
MIX_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
name: Build on Windows
runs-on: windows-2019
env:
CC: gcc
MAKE: make
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
with:
elixir-version: '1.13.x' # Define the elixir version [required]
otp-version: '24.2.x' # Define the OTP version [required]
- name: Install choco
shell: powershell
run: |
Set-ExecutionPolicy -ExecutionPolicy Bypass
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
- name: Install bakeware dependencies
shell: powershell
run: choco install -y zstandard make
- name: Install Dependencies
shell: powershell
run: mix deps.get
- name: Run credo code analyser
shell: powershell
run: mix credo --strict
我什至使用 powershell 来完成它(尽管我不确定是否需要这样做)。
问题
但是我的 GitHub 操作代码返回此错误:
==> bakeware
mkdir "d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj"
mkdir "d:/a/market_manager/market_manager/_build/test/lib/bakeware/launcher"
mkdir "d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress"
mkdir: cannot create directory 'd:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress': No such file or directory
make: *** [Makefile:70: d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress] Error 1
could not compile dependency :bakeware, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile bakeware", update it with "mix deps.update bakeware" or clean it with "mix deps.clean bakeware"
** (Mix) Could not compile with "make" (exit status: 2).
细心的reader,你会注意到这部分说:
mkdir: cannot create directory 'd:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress': No such file or directory
研究
通过稍微更改 GitHub 操作并添加一个额外的步骤,我能够检查一些行为:
- name: Compile everything
shell: powershell
run: |
mkdir "d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj"
mkdir "d:/a/market_manager/market_manager/_build/test/lib/bakeware/launcher"
mkdir "d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress"
ls .\_build\test\lib\bakeware\obj\zstd\lib\decompress
Test-Path -Path "d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress"
mix deps.compile --all
mix compile
env:
CC: C:\ProgramData\Chocolatey\bin\gcc.exe
MAKE: C:\ProgramData\Chocolatey\bin\make.exe
在这段代码中,我手动创建了所需的文件夹,然后对它们进行断言。输出结果如下:
Directory: D:\a\market_manager\market_manager\_build\test\lib\bakeware
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2/2/2022 11:06 AM obj
d----- 2/2/2022 11:06 AM launcher
Directory: D:\a\market_manager\market_manager\_build\test\lib\bakeware\obj\zstd\lib
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2/2/2022 11:06 AM decompress
True
我们可以看到:
- 已创建所有目录
Test-Path
returnsTrue
,也就是说'd:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress'
确实存在
这只会让我更加困惑,因为错误仍然没有改变:
mkdir: cannot create directory 'd:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress': No such file or directory
make: *** [Makefile:70: d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress] Error 1
could not compile dependency :bakeware, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile bakeware", update it with "mix deps.update bakeware" or clean it with "mix deps.clean bakeware"
** (Mix) Could not compile with "C:\ProgramData\Chocolatey\bin\make.exe" (exit status: 2).
当我使用的每条命令毫无疑问地显示文件夹 确实存在 .
时,我真的无法理解错误 No such file or directory
问题
为什么我总是收到这个错误?
回答
用头撞墙几天,我想我终于想通了。
该命令因 cmd mkdir
的行为方式而失败,因为它的行为与 poewrshell 中的不同。
通过将 Makefile
更改为仅在文件夹不存在时才创建文件夹,我能够在解决问题的同时仍然保持向后兼容性,这是我的要求之一。
我已经提交了关于此修复的 PR,在撰写本文时,我很高兴地宣布它已经合并到 master 中:
背景
我正在尝试使用 Windows 和 Bakeware 进行 Github 操作,因为我正在尝试使用它创建一个版本。
但是,我在创建文件夹时遇到了意外问题。
代码
以下是 github 操作,是该问题的最小工作示例。 基本上,所有步骤都有效,除了创建单个文件夹:
name: build
env:
MIX_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
name: Build on Windows
runs-on: windows-2019
env:
CC: gcc
MAKE: make
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
with:
elixir-version: '1.13.x' # Define the elixir version [required]
otp-version: '24.2.x' # Define the OTP version [required]
- name: Install choco
shell: powershell
run: |
Set-ExecutionPolicy -ExecutionPolicy Bypass
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
- name: Install bakeware dependencies
shell: powershell
run: choco install -y zstandard make
- name: Install Dependencies
shell: powershell
run: mix deps.get
- name: Run credo code analyser
shell: powershell
run: mix credo --strict
我什至使用 powershell 来完成它(尽管我不确定是否需要这样做)。
问题
但是我的 GitHub 操作代码返回此错误:
==> bakeware
mkdir "d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj"
mkdir "d:/a/market_manager/market_manager/_build/test/lib/bakeware/launcher"
mkdir "d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress"
mkdir: cannot create directory 'd:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress': No such file or directory
make: *** [Makefile:70: d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress] Error 1
could not compile dependency :bakeware, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile bakeware", update it with "mix deps.update bakeware" or clean it with "mix deps.clean bakeware"
** (Mix) Could not compile with "make" (exit status: 2).
细心的reader,你会注意到这部分说:
mkdir: cannot create directory 'd:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress': No such file or directory
研究
通过稍微更改 GitHub 操作并添加一个额外的步骤,我能够检查一些行为:
- name: Compile everything
shell: powershell
run: |
mkdir "d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj"
mkdir "d:/a/market_manager/market_manager/_build/test/lib/bakeware/launcher"
mkdir "d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress"
ls .\_build\test\lib\bakeware\obj\zstd\lib\decompress
Test-Path -Path "d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress"
mix deps.compile --all
mix compile
env:
CC: C:\ProgramData\Chocolatey\bin\gcc.exe
MAKE: C:\ProgramData\Chocolatey\bin\make.exe
在这段代码中,我手动创建了所需的文件夹,然后对它们进行断言。输出结果如下:
Directory: D:\a\market_manager\market_manager\_build\test\lib\bakeware
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2/2/2022 11:06 AM obj
d----- 2/2/2022 11:06 AM launcher
Directory: D:\a\market_manager\market_manager\_build\test\lib\bakeware\obj\zstd\lib
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2/2/2022 11:06 AM decompress
True
我们可以看到:
- 已创建所有目录
Test-Path
returnsTrue
,也就是说'd:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress'
确实存在
这只会让我更加困惑,因为错误仍然没有改变:
mkdir: cannot create directory 'd:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress': No such file or directory
make: *** [Makefile:70: d:/a/market_manager/market_manager/_build/test/lib/bakeware/obj/zstd/lib/decompress] Error 1
could not compile dependency :bakeware, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile bakeware", update it with "mix deps.update bakeware" or clean it with "mix deps.clean bakeware"
** (Mix) Could not compile with "C:\ProgramData\Chocolatey\bin\make.exe" (exit status: 2).
当我使用的每条命令毫无疑问地显示文件夹 确实存在 .
时,我真的无法理解错误No such file or directory
问题
为什么我总是收到这个错误?
回答
用头撞墙几天,我想我终于想通了。
该命令因 cmd mkdir
的行为方式而失败,因为它的行为与 poewrshell 中的不同。
通过将 Makefile
更改为仅在文件夹不存在时才创建文件夹,我能够在解决问题的同时仍然保持向后兼容性,这是我的要求之一。
我已经提交了关于此修复的 PR,在撰写本文时,我很高兴地宣布它已经合并到 master 中: