Search code examples
gitfilenamesnetlify

Netlify unable to clone because Git cannot process "File name too long"


I try to build mkdocs build this repo, and it's failed because there are file whose name is long:

11:53:17 AM: build-image version: e70ad4c6ce38c2b84143366f988574c7090c7a66 (focal)
11:53:17 AM: buildbot version: 4c288ae79a050d892a0d956d88b51697b8d4b77a
11:53:17 AM: Fetching cached dependencies
11:53:17 AM: Failed to fetch cache, continuing with build
11:53:17 AM: Starting to prepare the repo for build
11:53:17 AM: No cached dependencies found. Cloning fresh repo
11:53:17 AM: git clone --filter=blob:none https://github.com/QuaCau-TheSphere/OPT-web-netlify
11:53:18 AM: Preparing Git Reference pull/81/head
11:53:19 AM: Failed during stage "preparing repo": error: unable to create file docs/⚡Hiểu biết sâu/Khoa học máy tính/Đánh đổi/Lập trình viên khó chịu với hệ thống low code không phải vì nó ưu tiên sự tiện lợi và chi phí thấp cho người dùng, mà vì nó được tiếp thị như là một giải pháp hoàn hảo có thể giải quyết được mọi nhu cầu thực tế.md: File name too long
error: unable to create file docs/⚡Hiểu biết sâu/Nhân học/Diễn giải và mô tả/Diễn giải/Một phần quan trọng của sự kiến tạo cuộc đá gà thành một văn bản là một quá trình hội thoại và đối mặt với một số người Bali chứ không phải là việc đọc và diễn giải văn hóa đằng sau lưng họ.md: File name too long
error: unable to create file docs/⚡Hiểu biết sâu/Nhân học/Diễn giải và mô tả/Uy quyền trong việc diễn giải dựa trên sự loại bỏ các quá trình đối thoại. Uy quyền hoàn toàn chỉ nhấn mạnh vào đối thoại che dấu đi tiến trình văn bản hóa vốn là một thực tế không thể chối bỏ được.md: File name too long
error: unable to create file docs/⚡Hiểu biết sâu/Nhân học/Nhiều ngành học khác xem bạn là kết quả của những mối quan hệ nhân quả với một thứ bên ngoài. Nhân học chỉ chú trọng đến việc nói rằng bạn có thể khác biệt, rằng bạn còn có thể là người khác.md: File name too long
Note: switching to "FETCH_HEAD".

You are in "detached HEAD" state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 5c13cb4 DELETE FILE : docs/📜 Tài nguyên/Lập trình/Debug/Việc chia các lệnh trong kịch bản thành các hàm nhỏ hơn sẽ giúp dễ bắt lỗi hơn.md
: exit status 1
11:53:19 AM: Error checking out to pull/81/head
11:53:19 AM: Failing build: Failed to prepare repo

I don't know how to fix that because Netlify cloning it before applying netlify.toml. I can clone it to my machine just fine. I understand I can simply make the file name smaller, but is there any other way to fix this?


Solution

  • Despite what the comment section says, Linux does have a maximum filename length and maximum path length; it just varies based on kernel parameters and filesystem type. Most common filesystems limit individual filenames (not the path, just the file's name itself including any extensions) to 255 bytes; other filesystems may have different limits. It's also possible that Netlify's using an encoding mechanism other than UTF-8, which could make filenames even larger for the same number of characters.

    It looks like all the rejected filenames are longer than 255 bytes, based on wc -c on macOS:

    288 bytes: Lập trình viên khó chịu với hệ thống low code không phải vì nó ưu tiên sự tiện lợi và chi phí thấp cho người dùng, mà vì nó được tiếp thị như là một giải pháp hoàn hảo có thể giải quyết được mọi nhu cầu thực tế.md
    266 bytes: Một phần quan trọng của sự kiến tạo cuộc đá gà thành một văn bản là một quá trình hội thoại và đối mặt với một số người Bali chứ không phải là việc đọc và diễn giải văn hóa đằng sau lưng họ.md
    272 bytes: Uy quyền trong việc diễn giải dựa trên sự loại bỏ các quá trình đối thoại. Uy quyền hoàn toàn chỉ nhấn mạnh vào đối thoại che dấu đi tiến trình văn bản hóa vốn là một thực tế không thể chối bỏ được.md
    263 bytes: Nhiều ngành học khác xem bạn là kết quả của những mối quan hệ nhân quả với một thứ bên ngoài. Nhân học chỉ chú trọng đến việc nói rằng bạn có thể khác biệt, rằng bạn còn có thể là người khác.md
    

    Since we don't know what encodings or filesystems or kernel parameters are involved on Netlify's side, and since Netlify is unlikely to overhaul their systems to fit these files, your only useful option is to shorten these to something less than 255 bytes. My Vietnamese is pretty rough (sorry) but it looks like these specific filenames are less "descriptions of the content" and more "the content itself"; if that's accurate, then it should be pretty straightforward to rename the files with git mv longname shortername and push.