[英]Google Clould Functions deploy: EROFS: read-only file system
I'm trying to deploy my api to Google Cloud Functions, and I'm getting this:我正在尝试将我的 api 部署到 Google Cloud Functions,我得到了这个:
EROFS: read-only file system, mkdir '/user_code/uploads' EROFS:只读文件系统,mkdir '/user_code/uploads'
⚠ functions[post]: Deployment error. Function load error:
Code in file index.js can't be loaded. Is there a syntax error in your code?
Detailed stack trace: Error: EROFS: read-only file system, mkdir '/user_code/uploads'
at Error (native)
at Object.fs.mkdirSync (fs.js:932:18)
at Function.sync (/user_code/node_modules/multer/node_modules/mkdirp/index.js:71:13)
at new DiskStorage (/user_code/node_modules/multer/storage/disk.js:21:12)
at module.exports (/user_code/node_modules/multer/storage/disk.js:65:10)
at new Multer (/user_code/node_modules/multer/index.js:15:20)
at multer (/user_code/node_modules/multer/index.js:95:12)
at Object.<anonymous> (/user_code/api/user.js:105:46)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
Everything in the Cloud Functions runtime is read-only except for os.tmpdir()
(which is likely going to be /tmp
, but you shouldn't assume that). Cloud Functions 运行时中的所有内容都是只读的,除了os.tmpdir()
(可能是/tmp
,但您不应该假设)。 If you have any code (in api/user.js
for example) that attempt to write anywhere else, it'll error.如果您有任何代码(例如在api/user.js
中)尝试在其他任何地方编写代码,则会出错。
Same issue for python, above answer worked for me, but putting this for clarity. python的同样问题,上面的答案对我有用,但为了清楚起见。 My error -我的错误——
File "/env/local/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 753, in download_to_filename
with open(filename, "wb") as file_obj:
OSError: [Errno 30] Read-only file system: 'testFile.zip'
Googles documentation can be found here .可以在此处找到Google 的文档。
While Cloud Storage is the recommended solution for reading and writing files in App Engine, if your app only needs to write temporary files, you can use standard Python 3.7 methods to write files to a directory named /tmp.虽然 Cloud Storage 是在 App Engine 中读取和写入文件的推荐解决方案,但如果您的应用程序只需要写入临时文件,您可以使用标准 Python 3.7 方法将文件写入名为 /tmp 的目录。
All files in this directory are stored in the instance's RAM, therefore writing to /tmp takes up system memory.此目录中的所有文件都存储在实例的 RAM 中,因此写入 /tmp 会占用系统内存。 In addition, files in the /tmp directory are only available to the app instance that created the files.此外,/tmp 目录中的文件仅对创建这些文件的应用程序实例可用。 When the instance is deleted, the temporary files are deleted.当实例被删除时,临时文件也被删除。
Gen1 cloud functions are read-only systems however Gen2 cloud functions aren't. Gen1 云函数是只读系统,而 Gen2 云函数不是。 Id recommend changing your function to be Gen2 ( be careful, this might interfere with other config as gen 2 can be considered as a cloud run)我建议将您的 function 更改为 Gen2(小心,这可能会干扰其他配置,因为 gen 2 可被视为云运行)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.