LoginSignup
1
0

More than 1 year has passed since last update.

Windows Gitはデフォルトでcase-insensitiveだが、GitHub Actions [ubuntu-latest]はcase-sensitiveである罠

Last updated at Posted at 2021-07-09

Windows GitとGitHub Actions [ubuntu-latest]でcase-sensitiveかどうかが異なる

Gitは、Windows環境下ではデフォルトではファイル名の大文字・小文字を区別しない(case-insensitive)。一方、GitHub Actions、というよりUbuntu環境のデフォルトでは、ファイル名の大文字・小文字を区別する(case-sensitive)。
正確には、Gitは導入されたOSによってcase-sensitivityが変わるようである。Windows環境はデフォルトがcase-insensitiveなので、Git上でもcase-insensitiveになる。同様にGitHub Actionsはruns-onで環境を指定でき、それによって大文字・小文字を区別するかどうかが異なるが、人気があると思われるubuntu-latestは区別する。

何が問題か?

例えば、WindowsマシンでTypeScriptを書いており、moduleA.tsというファイルでmoduleを定義し、同じディレクトリのB.tsというファイルで参照するとする。

B.ts
import { *** } from './moduleA';

この内容でcommitし、GitHub Actionsを設定してビルドが成功しているとしよう。
ここで、moduleA.tsModuleA.tsに変えたいと思ったとする。

B.ts
import { *** } from './ModuleA';

これをcommit・pushすると、Gitのデフォルトはcase-insensitiveなので、ファイル名がmoduleA.tsのままになってしまう。一方、B.tsの中身はしっかりModuleA.tsを参照するように変化する。
これでActionsを動かした場合、リポジトリにはModuleA.tsというファイルが存在していないので、B.tsのビルドに失敗する。

どう回避するか?

最も簡単なのは、Gitにcase-sensitiveになってもらうことであると思われる。

$ git config core.ignorecase false

別の方法として、GitHub Actionsの環境をwindows-latestのようにcase-insensitiveなものにするという方法が考えられるが、別の問題が起こりそうだし、試したことがないので個人的にはあまりオススメしない。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0