firebase-tools: Could not read source directory. Remove links and shortcuts and try again.
Version info
firebase-tools: 3.17.4
Platform Information
OS X
Steps to reproduce
Deploy a firebase function as normal
firebase deploy --only functions:myFunction
Expected behavior
Function is deployed or a descriptive error is displayed
Actual behavior
I received:
✔ functions: Finished running predeploy script.
i functions: ensuring necessary APIs are enabled...
Error: Server Error. getaddrinfo ENOTFOUND servicemanagement.googleapis.com servicemanagement.googleapis.com:443
However, I kept re-attempting a few times without making changes and also received the following about ~5 times:
Error: Could not read source directory. Remove links and shortcuts and try again.
The “Could not read source directory” error also sometimes took up to 2 minutes to appear after executing the command, which leads me to believe its network related and nothing to do with my local setup, especially as the function eventually deployed after a few re-attempts.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 25 (5 by maintainers)
In case anyone else runs into this, I had a temporary Emacs file in the functions directory that was causing this error. The
--debugflag helped me find it. 😃For any future weary Google searchers, I get this issue when connected to my VPN (TunnelBear). If I turn the VPN off, the deploy works just fine.
I found the problem (a temp emacs file, which is a dead symlink) using
--debugafter finding this issue. It would be really helpful to just print the name of the offending file in the error message!I had the same issue, so I re-ran my deploy with
--debugand discovered that my deploy user was getting a 403 on the GET https://runtimeconfig.googleapis.com/v1beta1/projects/myproject/configs call.I added the
Cloud RuntimeConfig Adminrole, and a handful of permissions including these, and that resolved it:(I’m not sure which of these are necessary but it might provide someone in the future some pointers!)
@divyesm please open a new issue with the appropriate information and we can try to help debug it. Include as much of the
--debugoutput orfirebase-debug.logfile as possible. Thanks.I think it might be the
tsc watchthat’s interferring with deployment, since it scans all the files. I would stoptsc watchwhile you are deployingDeleting
node_modulesandpackage-lock.jsonand rerunningnpm installfixed the problem for me.I was able to use this thread to solve my issues with Cloud Build when deploying, if anyone is looking for this later.
The Cloud Build Service Account was the account I added permissions to, which altogether included these to end up with a successful build and deploy:
This error message is almost definitely a red herring - I get it intermittently whenever there are network issues talking to the firebase servers (which seems to be ALL THE TIME recently).
Thanks for clarifying. I think that error message is unrelated to the network issues, since it comes from this line: https://github.com/firebase/firebase-tools/blob/master/lib/prepareFunctionsUpload.js#L64. So it happens when the zipping process encounters an issue. Can you run the deploy command again with the --debug flag? That’ll give us more info, and tell us if the error message is wrong.