Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any func command does not work #1804

Closed
seed-of-apricot opened this issue Feb 5, 2020 · 12 comments · Fixed by #1919
Closed

Any func command does not work #1804

seed-of-apricot opened this issue Feb 5, 2020 · 12 comments · Fixed by #1919

Comments

@seed-of-apricot
Copy link

I installed the package globally, created a new project through VSCode extension and tried to run the sample without any changes. The error I get is:

> func start

events.js:298
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Users\apricot\AppData\Roaming\nvm\v13.7.0\node_modules\azure-functions-core-tools\bin/func ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\\Users\\apricot\\AppData\\Roaming\\nvm\\v13.7.0\\node_modules\\azure-functions-core-tools\\bin/func',
  path: 'C:\\Users\\apricot\\AppData\\Roaming\\nvm\\v13.7.0\\node_modules\\azure-functions-core-tools\\bin/func',
  spawnargs: [ 'start' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hogehoge@1.0.0 start: `func start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hogehoge@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.        

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\apricot\AppData\Roaming\npm-cache\_logs\2020-02-05T09_13_13_764Z-debug.log

So, how about func itself?

C:\Users\apricot\src\user\directory\hogehoge>func init fugafuga
events.js:298
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Users\apricot\AppData\Roaming\nvm\v13.7.0\node_modules\azure-functions-core-tools\bin/func ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\\Users\\apricot\\AppData\\Roaming\\nvm\\v13.7.0\\node_modules\\azure-functions-core-tools\\bin/func',
  path: 'C:\\Users\\apricot\\AppData\\Roaming\\nvm\\v13.7.0\\node_modules\\azure-functions-core-tools\\bin/func',
  spawnargs: [ 'init', 'fugafuga' ]
}

What happens in line 298...?
I installed both 2.7.2100 and 3.0.2106 but neither has worked.

@joshuapetryk
Copy link

Getting same issue. It appears that the func.exe application is not getting installed via NPM. I worked around this by downloading the zip from https://functionscdn.azureedge.net/public/3.0.2106/Azure.Functions.Cli.win-x64.3.0.2106.zip and extracting it into the bin folder manually.

It appears to be an issue with the install.js script. I got the following error when installing via NPM

npm install -i g azure-functions-core-tools@3 --unsafe-perm true 

> azure-functions-core-tools@3.0.2106 postinstall C:\node_modules\azure-functions-core-tools
> node lib/install.js

attempting to GET "https://functionscdn.azureedge.net/public/3.0.2106/Azure.Functions.Cli.win-x64.3.0.2106.zip"
[------------------] Downloading Azure Functions Core Toolsnpm WARN saveError ENOENT: no such file or directory, open 'C:\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'C:\package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.

+ azure-functions-core-tools@3.0.2106
+ g@2.0.1
added 54 packages from 34 contributors and audited 112 packages in 1.591s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities

@ankitkumarr
Copy link
Contributor

@joshuapetryk, your error is because you have g instead of -g in the install command. It needs to be npm install -g azure-functions-core-tools@3 --unsafe-perm true

@seed-of-apricot, are other npm packages working ok for you, if you have them? What happens when you do C:\Users\apricot\AppData\Roaming\nvm\v13.7.0\node_modules\azure-functions-core-tools\bin\func --version

Can you check the contents of C:\Users\apricot\AppData\Roaming\nvm\v13.7.0\node_modules\azure-functions-core-tools\bin ?

And if nothing works, I would suggest removing C:\Users\apricot\AppData\Roaming\nvm\v13.7.0\node_modules\azure-functions-core-tools and installing core-tools again. I can't repro this and I think it's likely that your first install somehow didn't complete properly.

@Basaingeal
Copy link

Basaingeal commented Feb 13, 2020

I'm having the same problem. After installing with the npm install -g azure-functions-core-tools@3 --unsafe-perm true command, func calls don't work. There is no bin folder added to azure-functions-core-tools in node_modules.

This install process looks like this:

❯ npm install -g azure-functions-core-tools@3 --unsafe-perm true
C:\Users\Michael.Currie\AppData\Roaming\npm\func -> C:\Users\Michael.Currie\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js
C:\Users\Michael.Currie\AppData\Roaming\npm\azurefunctions -> C:\Users\Michael.Currie\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js
C:\Users\Michael.Currie\AppData\Roaming\npm\azfun -> C:\Users\Michael.Currie\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js

> azure-functions-core-tools@3.0.2106 postinstall C:\Users\Michael.Currie\AppData\Roaming\npm\node_modules\azure-functions-core-tools
> node lib/install.js

attempting to GET "https://functionscdn.azureedge.net/public/3.0.2106/Azure.Functions.Cli.win-x64.3.0.2106.zip"
[------------------] Downloading Azure Functions Core Tools+ azure-functions-core-tools@3.0.2106
added 53 packages from 33 contributors in 1.278s

It never downloads a 219 MB zip and finishes in a few seconds.

The issue persists through uninstalls/reinstalls.

@joshuapetryk
Copy link

Thanks - Missed the -g switch. I am still getting the same issue though - the zip file doesn't actually download.

@ghost ghost added the no-recent-activity label Feb 17, 2020
@ghost
Copy link

ghost commented Feb 17, 2020

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@Tjeerd-menno
Copy link

I'm getting the same error.

I've used 'npm i -g azure-functions-core-tools@3 --unsafe-perm true' to install the tools from an elevated command prompt (Windows Terminal) it installs fine, but any func command results in the mentioned error.

uninstalling then reinstalling does not solve the issue.

@ghost
Copy link

ghost commented Feb 22, 2020

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@nibblesnbits
Copy link

Same issue with me. Looking at the error message:

events.js:298
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Users\sgcol\AppData\Roaming\nvm\v13.8.0\node_modules\azure-functions-core-tools\bin/func ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\\Users\\sgcol\\AppData\\Roaming\\nvm\\v13.8.0\\node_modules\\azure-functions-core-tools\\bin/func',  
  path: 'C:\\Users\\sgcol\\AppData\\Roaming\\nvm\\v13.8.0\\node_modules\\azure-functions-core-tools\\bin/func',
  spawnargs: [ 'host', 'start' ]
}
The terminal process terminated with exit code: 1

I think the key problem may be the path: C:\Users\sgcol\AppData\Roaming\nvm\v13.8.0\node_modules\azure-functions-core-tools\bin/func. The final path delimiter is a forward slash on my Windows machine. I'm guessing that's why it can't find the file.

If someone can point me in the right direction of where this path is put together, I'd be happy to bring in a PR for it.

@anthonychu
Copy link
Member

@nibblesnbits looks like that is here: https://github.com/Azure/azure-functions-core-tools/blob/dev/src/Azure.Functions.Cli/npm/lib/main.js#L12

This probably should use path.join, maybe a recent change in Node caused this to no longer work.

// @ankitkumarr

@ankitkumarr
Copy link
Contributor

ankitkumarr commented Mar 5, 2020

Thank you all for your patience. Thanks @mhoeger for finding the root cause (below) offline!

The issue was during the unzip step where unzipper (we use to unzip) would, intermittently, exit abruptly when using Node 13. Marie was able to repro, and found that this issue was likely the cause - ZJONSSON/node-unzipper#168

Once we updated the unzipper package in the repro, the issue seemed to have resolved. We need to update our package.json and npm-shrinkwrap.json. @nibblesnbits, if you would like to make a PR to update https://github.com/Azure/azure-functions-core-tools/blob/dev/src/Azure.Functions.Cli/npm/package.json and https://github.com/Azure/azure-functions-core-tools/blob/dev/src/Azure.Functions.Cli/npm/npm-shrinkwrap.json with a newer version of unzipper, you are more than welcome to do so. :)

For now, if this happens you can follow these steps to mitigate yourselves --

  1. Go to the installed location.C:\Users\sgcol\AppData\Roaming\nvm\v13.8.0\node_modules\azure-functions-core-tools\ in the example above.
  2. Run npm install unzipper@0.10.7
  3. Run npm .\lib\install.js node .\lib\install.js from that directory

These steps should download and extract the core-tools to the bin location and have it setup for executions.
Please let us know if you continue to see issues.

@seed-of-apricot
Copy link
Author

seed-of-apricot commented Mar 22, 2020

@ankitkumarr Sorry for not responding to your mention for a while.

I have tried the steps you described in the latest comment and made it work, thank you!
(You though misattributed npm .\lib\install.js with node .\lib\install.js)

@ankitkumarr
Copy link
Contributor

@seed-of-apricot, thanks for the update. I will update my comment. With the interest of time in mind, we updated the packages and this should be fixed in the next release.

@ghost ghost locked as resolved and limited conversation to collaborators May 1, 2020
Xefir pushed a commit to Capgemini-nantes-df/azure-functions-core-tools that referenced this issue Jun 2, 2020
ankitkumarr pushed a commit that referenced this issue Jun 10, 2020
Co-authored-by: Michel Roux <michel.roux@capgemini.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants