pulyaevskiy / firebase-functions-interop

Firebase Functions Interop Library for Dart.
BSD 3-Clause "New" or "Revised" License
191 stars 52 forks source link

Corrupted `packages` file generated at build #58

Open ghost opened 4 years ago

ghost commented 4 years ago

When I run pub run build_runner build --output=build as admin (https://github.com/pulyaevskiy/firebase-functions-interop/issues/56), the corrupted file functions/build/node/packages is generated.

If I run firebase deploy --debug --only functions, I get the following error:

[2019-07-11T18:19:46.508Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Thu, 11 Jul 2019 18:19:46 GMT, server=ESF, cache-contro
l=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="46,43,39", accept-ranges=none, transfer-encoding=chunked
[2019-07-11T18:19:46.934Z] Error: EPERM: operation not permitted, stat 'C:\Users\hugoc\IdeaProjects\Flutter\buster\functions\build\node\packages'

Error: Could not read source directory. Remove links and shortcuts and try again.

After deleting packages, I'm able to deploy.

I'm using the exact pubspec.yaml, node/index.dart and build.yaml, as shown in the readme.

gazialankus commented 4 years ago

I just ran into this as well in Windows. Back in the day that file was a junction with an absolute path reference. Now it's a symlink with a relative path reference and it does not work. Not sure what should be done.

gazialankus commented 4 years ago

This is probably why we're running into this problem. https://github.com/dart-lang/sdk/issues/33966 dart:io's Link.create used to create junctions but now creates symlinks in Windows.

Firebase CLI does not seem to like symlinks. I guess we could add a npm postbuild command that replaces build/node/packages with a junction.

Not sure who is creating the build/node/packages symlink, anyway. It is created after pub run build_runner build --output=build but I'm not sure where exactly is the link creating code.

basketball-ico commented 4 years ago

@hugocbpassos @gazialankus i am new with this package and node, can you show me a example project? i can't setup a readme example :(

gazialankus commented 4 years ago

@basketball-ico StackOverflow is probably better for this. The readme file is quite sufficient, actually. Ask in SO and we can answer in more detail.

basketball-ico commented 4 years ago

@gazialankus Thanks, i have the same issue here and #https://github.com/pulyaevskiy/firebase-functions-interop/issues/56 , which version of dart I need to use to make this work? i really want to test it

gazialankus commented 4 years ago

I'm using Dart 2.3.2, I didn't try 2.4.0.

basketball-ico commented 4 years ago

@gazialankus I tested with Dart 2.1 - 2.2 - 2.3.2 - 2.41 - 2.5.0.2-dev-1 And ever get this errors fail

gazialankus commented 4 years ago

Wow you really tried all versions, huh. I'm sorry you're having this issue. I use IntelliJ, not VS Code. Did you really try the steps here one by one? https://github.com/pulyaevskiy/firebase-functions-interop/blob/master/README.md Could you try on the command line rather than VS Code?

basketball-ico commented 4 years ago

@gazialankus yes, check https://github.com/basketball-ico/functions_test- Also I test on the command line and is the same of run in vs code and pub run build_runner build --output=build not have problems in console, but the files in package folder have errors.

Also if I run pub run build_runner build --output=build second time I got this like https://github.com/pulyaevskiy/firebase-functions-interop/issues/56 :

FileSystemException: Cannot create link, path = 'build\node\packages' (OS Error: A required privilege is not held by the client.
, errno = 1314)

I solve with administrator command line but why I need to run this in an Administrator Command line?

and when try firebase deploy --only functions i got

Error: Could not read source directory. Remove links and shortcuts and try again.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ deploy: `firebase deploy --only functions`
npm ERR! Exit status 1

dart 2.3.2

Also if I remove the build/node/packages.symlink I can deploy but it take some time to deploying it is only a simple function and have 37.9 MB like https://github.com/pulyaevskiy/firebase-functions-interop/issues/57

i  deploying functions
i  functions: ensuring necessary APIs are enabled...
+  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (37.9 MB) for uploading
+  functions: functions folder uploaded successfully
i  functions: updating Node.js 8 function helloWorld(us-central1)...
+  functions[helloWorld(us-central1)]: Successful update operation.

+  Deploy complete!

Thanks, please help me 🤗

gazialankus commented 4 years ago

This is what at also have. I remove the packages symlink and I also get a huge upload like 40mb.

I'm able to use IntelliJ but I don't know about VS Code. I think the only real issue you have is about running it locally. You run it using npm. After adding this https://github.com/pulyaevskiy/firebase-functions-interop/blob/master/README.md#7-scripts-optional you can say npm serve or npm run serve (forgot which) and you can run locally.

If you fix your IDE, you will be same as what I have here...

basketball-ico commented 4 years ago

@gazialankus I solve the error of VScode by excluding the build folder for analysis like https://github.com/pulyaevskiy/firebase-functions-interop/blob/master/analysis_options.yaml,

This is good?

But i can't deploy

Error: Could not read source directory. Remove links and shortcuts and try again.

what is the solution you said

Firebase CLI does not seem to like symlinks. I guess we could add a npm postbuild command that replaces build/node/packages with a junction. Thanks