英文:
How to fix Google-cloud-sdk 156.0.0 "There are too many files in your application for changes in all of them to be monitored."?
问题
我刚刚在OSX上安装了Go 1.6.4和google-cloud-sdk 1.56.0.0。
当我尝试运行本地的dev_server时,我收到以下警告信息:
/Users/Bryan/go/src/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/mtime_file_watcher.py:156: UserWarning: 您的应用程序中的文件太多,无法监视所有文件的更改。您可能需要重新启动开发服务器才能看到某些文件的更改。
我该如何解决这个问题?
这是项目的文件列表,只有4个文件:
$ ls
total 32
drwxrwxrwx 6 Bryan staff 204 May 23 15:57 .
drwxr-xr-x 10 Bryan staff 340 May 25 18:39 ..
-rwxrwxrwx@ 1 Bryan staff 69 Mar 22 09:40 app.yaml
-rw-r--r-- 1 Bryan staff 554 Mar 28 09:26 index.yaml
-rwxrwxrwx@ 1 Bryan staff 3015 May 25 18:36 skincare.go
-rw-r--r-- 1 Bryan staff 870 May 3 09:18 skincare_test.go
我还遇到一个问题,即"go get"尝试编译代码而不是下载远程包"google.golang.org/appengine"。
$ go get
import "google.golang.org/appengine"被忽略,"go get"产生以下错误:
./skincare.go:31: undefined: appengine.Context
编辑附加信息:
我尝试使用-u标志强制更新:
$ go get -u
package skincarereview: directory "/Users/Bryan/go/src/skincarereview"没有使用已知的版本控制系统
这是当我尝试运行本地服务器时的错误输出:
$ /Users/Bryan/go/src/google-cloud-sdk/bin/dev_appserver.py app.yaml
INFO 2017-05-30 14:27:31,722 devappserver2.py:692] Skipping SDK update check.
INFO 2017-05-30 14:27:31,785 api_server.py:272] Starting API server at: http://localhost:60703
INFO 2017-05-30 14:27:31,789 dispatcher.py:205] Starting module "default" running at: http://localhost:8080
INFO 2017-05-30 14:27:31,793 admin_server.py:116] Starting admin server at: http://localhost:8000
/Users/Bryan/go/src/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/mtime_file_watcher.py:156: UserWarning: 您的应用程序中的文件太多,无法监视所有文件的更改。您可能需要重新启动开发服务器才能看到某些文件的更改。
'There are too many files in your application for '
ERROR 2017-05-30 14:27:36,123 go_runtime.py:182] Failed to build Go application: (Executed command: /Users/Bryan/go/src/google-cloud-sdk/platform/google_appengine/goroot/bin/go-app-builder -app_base /Users/Bryan/go/src/skincarereview -arch 6 -dynamic -goroot /Users/Bryan/go/src/google-cloud-sdk/platform/google_appengine/goroot -gopath /Users/Bryan/go -nobuild_files ^^$ -incremental_rebuild -unsafe -binary_name _go_app -extra_imports appengine_internal/init -work_dir /var/folders/mw/0y88j8_54bjc93d_lg3120qw0000gp/T/tmpEOVMVuappengine-go-bin -gcflags -I,/Users/Bryan/go/src/google-cloud-sdk/platform/google_appengine/goroot/pkg/darwin_amd64_appengine -ldflags -L,/Users/Bryan/go/src/google-cloud-sdk/platform/google_appengine/goroot/pkg/darwin_amd64_appengine skincare.go skincare_test.go)
/var/folders/mw/0y88j8_54bjc93d_lg3120qw0000gp/T/tmpEOVMVuappengine-go-bin/skincare.go:31: undefined: "google.golang.org/appengine".Context
2017/05/30 10:27:36 go-app-builder: build timing: 0×skip (5ms total), 11×compile (2.128s total), 0×link (0 total)
2017/05/30 10:27:36 go-app-builder: failed running compile: exit status 2
英文:
I just installed Go 1.6.4 and google-cloud-sdk 1.56.0.0 on osX.
When I attempt to run the local dev_server I get the following warning.
/Users/Bryan/go/src/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/mtime_file_watcher.py:156: UserWarning: There are too many files in your application for changes in all of them to be monitored. You may have to restart the development server to see some changes to your files.
How do I fix this?
Here is the project, there are only 4 files:
$ ls
total 32
drwxrwxrwx 6 Bryan staff 204 May 23 15:57 .
drwxr-xr-x 10 Bryan staff 340 May 25 18:39 ..
-rwxrwxrwx@ 1 Bryan staff 69 Mar 22 09:40 app.yaml
-rw-r--r-- 1 Bryan staff 554 Mar 28 09:26 index.yaml
-rwxrwxrwx@ 1 Bryan staff 3015 May 25 18:36 skincare.go
-rw-r--r-- 1 Bryan staff 870 May 3 09:18 skincare_test.go
I'm also having a problem that "go get" attempts to compile the code instead of downloading the remote packages "google.golang.org/appengine".
$ go get
# import "google.golang.org/appengine" is ignored and "go get" yields this error:
./skincare.go:31: undefined: appengine.Context
EDIT additional info:
I attempted to to force the update with the -u flag:
$ go get -u
package skincarereview: directory "/Users/Bryan/go/src/skincarereview" is not using a known version control system
This is the error output when I attempt to run the local server:
$ /Users/Bryan/go/src/google-cloud-sdk/bin/dev_appserver.py app.yaml
INFO 2017-05-30 14:27:31,722 devappserver2.py:692] Skipping SDK update check.
INFO 2017-05-30 14:27:31,785 api_server.py:272] Starting API server at: http://localhost:60703
INFO 2017-05-30 14:27:31,789 dispatcher.py:205] Starting module "default" running at: http://localhost:8080
INFO 2017-05-30 14:27:31,793 admin_server.py:116] Starting admin server at: http://localhost:8000
/Users/Bryan/go/src/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/mtime_file_watcher.py:156: UserWarning: There are too many files in your application for changes in all of them to be monitored. You may have to restart the development server to see some changes to your files.
'There are too many files in your application for '
ERROR 2017-05-30 14:27:36,123 go_runtime.py:182] Failed to build Go application: (Executed command: /Users/Bryan/go/src/google-cloud-sdk/platform/google_appengine/goroot/bin/go-app-builder -app_base /Users/Bryan/go/src/skincarereview -arch 6 -dynamic -goroot /Users/Bryan/go/src/google-cloud-sdk/platform/google_appengine/goroot -gopath /Users/Bryan/go -nobuild_files ^^$ -incremental_rebuild -unsafe -binary_name _go_app -extra_imports appengine_internal/init -work_dir /var/folders/mw/0y88j8_54bjc93d_lg3120qw0000gp/T/tmpEOVMVuappengine-go-bin -gcflags -I,/Users/Bryan/go/src/google-cloud-sdk/platform/google_appengine/goroot/pkg/darwin_amd64_appengine -ldflags -L,/Users/Bryan/go/src/google-cloud-sdk/platform/google_appengine/goroot/pkg/darwin_amd64_appengine skincare.go skincare_test.go)
/var/folders/mw/0y88j8_54bjc93d_lg3120qw0000gp/T/tmpEOVMVuappengine-go-bin/skincare.go:31: undefined: "google.golang.org/appengine".Context
2017/05/30 10:27:36 go-app-builder: build timing: 0×skip (5ms total), 11×compile (2.128s total), 0×link (0 total)
2017/05/30 10:27:36 go-app-builder: failed running compile: exit status 2
答案1
得分: 3
我只使用了一个较旧版本的appengine sdk,但我相信以下内容仍然正确。
主要问题是你的GOPATH中有google-cloud-sdk。这是不必要的。我将其安装在了我的路径中。但即使没有安装,它也应该根据你运行的可执行文件或脚本的位置来解析它的位置,并正确找到所有所需的sdk文件。同时,SDK大约有7500个文件,你只需要在GOPATH中有超过10000个文件(大约)才会出现“文件太多”的警告。因此,如果你在同一个GOPATH中有另一个(例如较旧的)SDK副本或其他大型项目,你几乎肯定会超过阈值。只需在Finder中找到/Users/Bryan/go,并使用“获取信息”来计算文件数量。
因此,要么将appengine SDK移出GOPATH,要么创建一个新文件夹,将其导出为新的GOPATH,并将项目文件(但不包括SDK)移动到该新文件夹中。这应该解决“文件太多”的问题。
另一个问题是你的应用实际上无法构建。正如你自己已经发现的那样,(直接)问题是缺少appengine包。
但获取google.golang.org/appengine的正确方法如下:
go get google.golang.org/appengine
请注意,在运行上述命令之前,必须正确设置GOPATH。它将获取google.golang.org/appengine及其所有依赖项。
一旦获取了所有所需的包(并修复了错误,如果有的话),它应该能够编译和运行而无任何问题。
英文:
I only used an older version of appengine sdk, but I believe below is still true.
The main issue is that you have google-cloud-sdk inside your GOPATH. This should not be necessary. I have it installed in my path. But even if not installed it should be resolving it's location relative to the executable or script you are running and should find all required sdk files properly. At the same time SDK is roughly 7500 files and you only need to have more than 10000 (approx) in your GOPATH to get that "to many files" warning. So, if you have another (e.g. older) copy of SDK or other big project inside same GOPATH, you are pretty much guaranteed to exceed the threshold. Just locate /Users/Bryan/go in Finder and use "Get Info" to count files.
So, either move appengine SDK outside of your GOPATH. Or make a new folder, export it as your new GOPATH and move your project files (but not SDK) to that new folder. This should fix the "too many files issue".
The other issue is that your app actually fails to build. And as you have already figured out yourself the (immediate) issue is missing appengine package.
But the correct way of getting google.golang.org/appengine is as follows:
go get google.golang.org/appengine
Though keep in mind that GOPATH must be set correctly before running the above command. It will fetch google.golang.org/appengine and all it's dependencies.
Once you have retrieved all required packages (and fixed errors, if any) it should compile and run without issues.
答案2
得分: 3
根据我的当前 SDK 版本(Google Cloud SDK 171.0.0
),dev_appserver.py
有一个名为 enable_watching_go_path
的选项。
将其设置为 False
可以消除警告。
我使用的命令是:
dev_appserver.py --enable_watching_go_path=False server/app.yml
英文:
With my current sdk version (Google Cloud SDK 171.0.0
) dev_appserver.py
has one option named enable_watching_go_path
.
Setting it to False
removed the warning.
The command I use is:
dev_appserver.py --enable_watching_go_path=False server/app.yml
答案3
得分: 2
对应的错误发生在 mtime_file_watcher.py 尝试监视 "GOPATH" 下的所有文件时,但文件太多,因此可以通过使用 app.yaml 的 skip_files 选项来检查 vendor、node_modules 和任意数量的文件来避免监视许多项目。
https://cloud.google.com/appengine/docs/standard/python/config/appref#skip_files
skip_files:
- .*node_modules
- .*vendor
- .*project-name-having-too-many-files
英文:
The corresponding error occurs when mtime_file_watcher.py tries to monitor all files under "GOPATH" but has too many files, so use the skip_files option of app.yaml to check vendor, node_modules and arbitrary number of files Can be avoided by excluding many projects to be monitored.
https://cloud.google.com/appengine/docs/standard/python/config/appref#skip_files
skip_files:
- .*node_modules
- .*vendor
- .*project-name-having-too-many-files
答案4
得分: 0
我正在使用仅适用于Go的App Engine SDK(1.9.54),而不是Cloud SDK,但遇到了相同的问题[https://stackoverflow.com/q/44703952/8181815]。
我通过将大型包和存储库移动到vendor/
目录中解决了这个问题。
英文:
I'm using just the App Engine SDK for Go (1.9.54), not the Cloud SDK, but have the same problem [https://stackoverflow.com/q/44703952/8181815].
I solved it by moving large packages and repositories to vendor/
dir.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论