# Windows と Docker、マウントボリュームを使用した開発における問題

**URL:** https://meta.discourse.org/t/problem-with-development-on-windows-with-docker-and-mounted-volume/139523
**Category:** Development
**Created:** [2020 年 1 月 23 日午前 10:35 UTC](https://meta.discourse.org/t/problem-with-development-on-windows-with-docker-and-mounted-volume/139523 "2020-01-23T10:35:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Nikolay](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@Nikolay](https://meta.discourse.org/u/Nikolay)
#### Post date: [2020 年 1 月 23 日午前 10:35 UTC](https://meta.discourse.org/t/problem-with-development-on-windows-with-docker-and-mounted-volume/139523/1 "2020-01-23T10:35:20Z")

</div>

こんにちは、Windows 上では開発できません。空白の画面が表示されてしまいます。コンソールを開くと、以下のエラーが表示されます。

```plaintext
(X) ember_jquery.js?1579775136.5740232:1 Uncaught Error: Errno::EEXIST: File exists @ dir_s_mkdir - /var/discourse/tmp/cache/assets/sprockets/v3.0/pr
  (in /home/gaijinsailor/.rbenv/versions/2.6.2/lib/ruby/2.6.0/fileutils.rb:239:in `mkdir')
    at ember_jquery.js?1579775136.5740232:1

```

これと類似のエラーが多数発生しています。

つまり、Discourse がスクリプトをロードできない状態です。スクリプトを別ウィンドウで開くと、以下のエラーが表示されます。

```plaintext
Script: http://localhost:3000/assets/locales/en_US.js?1579775136.5398135
Body: throw Error("Errno::EEXIST: File exists @ dir_s_mkdir - /var/discourse/tmp/cache/assets/sprockets/v3.0/x2\n (in /home/gaijinsailor/.rbenv/versions/2.6.2/lib/ruby/2.6.0/fileutils.rb:239:in `mkdir')")

```

そこで調査を進めたところ、問題は Sprockets にあることに気づきました。Windows から Docker 内に Discourse のディレクトリをマウントしているため、ファイルシステムが大文字小文字を区別しません。Sprockets は、ext4 のような Linux 型のファイルシステム（大文字小文字を区別するディレクトリが作成できるもの）でのみ動作するようです。

この問題に対する解決策はありますか？  
ありがとうございます

追記：この Sprockets の問題は GitHub でドキュメント化されています：[FileStore cache patch in v3.6 causes directory name collisions in Windows · Issue #283 · rails/sprockets · GitHub](https://github.com/rails/sprockets/issues/283)  
しかし、この issue はまだオープンで、解決策は見つかっていません ☹

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2020 年 1 月 28 日午前 6:36 UTC](https://meta.discourse.org/t/problem-with-development-on-windows-with-docker-and-mounted-volume/139523/2 "2020-01-28T06:36:40Z")

</div>

面白いことに、昨日 `@pixeltrix` がこれを見つけ、このハックを使って回避しました：

> <https://github.com/alphagov/e-petitions/commit/98f288501f5b9c8b6347c1c6009da7218ec7bea2>
>
> Sprockets 3.0 and later uses Base64 digests for cache paths and these
> present pr…oblems when used with NTFS on Windows which is case-insensitive.
> 
> By allowing the overriding of the cache path from an environment variable
> we can use a Docker volume to cache the asset compilation. This is actually
> faster on both Mac and Windows than the default path.

WSL2 をインストールして、当社の WSL2 設定を使用することを強くお勧めします。こちらの方がはるかに高速で、理解しやすいです：

> [@Install Discourse on Windows for development](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-windows-10-for-development/75149):
>
> information_source This tutorial has been tested on Windows 10 and 11. To set up a development environment for Discourse on Windows, you can do it using [Windows Subsystem for Linux](https://msdn.microsoft.com/en-us/commandline/wsl/install-win10) feature. This setup requires the WSL 2 installation. It is only available in Windows 10 builds 18917 or higher. We’ll assume that you already installed [Windows Subsystem for Linux 2 (Ubuntu)](https://docs.microsoft.com/en-us/windows/wsl/install) on your Windows 10 system. WARNING: Install Ubuntu 18.04, and not 20.04 since some installations will fail on 20.04. For m…

開発環境のインストールは簡単です。WSL2 をセットアップし、Docker をインストールしてから、当社の Docker 開発設定を使用するだけです。

> [@Install Discourse for development using Docker](https://meta.discourse.org/t/beginners-guide-to-install-discourse-for-development-using-docker/102009):
>
> Developing using Docker Since Discourse runs in Docker, you should be able to run Discourse directly from your source directory using a Discourse development container. white_check_mark Pros: No need to install any system dependencies, no configuration needed at all for setting up a development environment quickly. x Cons: Will be slightly slower than the native dev environment on Ubuntu, and much slower than a native install on MacOS. See also [Developing Discourse using a Dev Container](https://meta.discourse.org/t/developing-discourse-using-a-dev-container/336366) …

---

<div class="post-metadata">

### Author: ![Nikolay](https://avatars.discourse-cdn.com/v4/letter/n/a698b9/32.png) [@Nikolay](https://meta.discourse.org/u/Nikolay)
#### Post date: [2020 年 1 月 28 日午前 10:10 UTC](https://meta.discourse.org/t/problem-with-development-on-windows-with-docker-and-mounted-volume/139523/3 "2020-01-28T10:10:29Z")

</div>

どうもありがとうございます。ハックは機能しました。  
後で WSL2 を使ってみます。
