• 问题描述

    如题所述,VSCode无法实时显示文件变动,因为workspace空间太大,文件太多,而linux本身对此有限制。

    From vscode offical documents, you can fixed the problem using:

    # 查看file watcher limit
    cat /proc/sys/fs/inotify/max_user_watches
    # increase the limit
    $ vim /etc/sysctl.conf
    fs.inotify.max_user_watches=524288 # 新增这么一行
    $ sudo sysctl -p
    

    如果是在docker container内部,上述方案最后会出现:

    sysctl: setting key "fs.inotify.max_user_watches": Read-only file system

    From Increase fs.inotify.max_user_watches in docker container #628, Docker mount /proc as read-only since many of its knobs are global. If you run that same command on the host, the container will transparently inherit the new setting.

  • 解决方案

    直接在容器所在宿主机上运行上述方案,当宿主机更改,容器也会自动更新。

  • References

  1. “Visual Studio Code is unable to watch for file changes in this large workspace” (error ENOSPC)
  2. Increase fs.inotify.max_user_watches in docker container #628

更多推荐