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

Error: spawn nmcli ENOENT (Linux/Raspberry Pi) #167

Open
1 of 2 tasks
WesWeCan opened this issue Aug 17, 2021 · 15 comments
Open
1 of 2 tasks

Error: spawn nmcli ENOENT (Linux/Raspberry Pi) #167

WesWeCan opened this issue Aug 17, 2021 · 15 comments
Labels

Comments

@WesWeCan
Copy link

Cannot scan (and possible also connect) for WiFi networks on Linux (Raspberry Pi)

Expected Behavior

Returning a list of networks wen calling wifi.scan()

Current Behavior

The following error emerges:

Error: spawn nmcli ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19) at onErrorNT (internal/child_process.js:465:16) at processTicksAndRejections (internal/process/task_queues.js:80:21) { errno: -2, code: 'ENOENT', syscall: 'spawn nmcli', path: 'nmcli', spawnargs: [ '--terse', '--fields', 'active,ssid,bssid,mode,chan,freq,signal,security,wpa-flags,rsn-flags', 'device', 'wifi', 'list', 'ifname', 'wlan0' ], cmd: 'nmcli --terse --fields active,ssid,bssid,mode,chan,freq,signal,security,wpa-flags,rsn-flags device wifi list ifname wlan0' }

Affected features

  • node API
  • cli

Possible Solution

Steps to Reproduce (for bugs)

Run wifi.scan() on raspberry pi in node.js project

Your Environment

Raspberry Pi - Node 14

  • OS: Rasbian
  • node-wifi version ^2.0.15
  • wifi card: (on linux, use command lspci | egrep -i --color 'network|ethernet')
@friedrith
Copy link
Owner

Hello,
Can you try to run the command nmcli --terse --fields active,ssid,bssid,mode,chan,freq,signal,security,wpa-flags,rsn-flags device wifi list ifname wlan0 in a terminal and print the result here?

@WesWeCan
Copy link
Author

Out of the box, nothing happens. It just waits for the next command.

But if I do the following:
sudo systemctl disable dhcpcd
sudo systemctl stop dhcpcd
sudo reboot now

Then I get a list of networks in the form as the fields in your command.
It is worth noting that some networks have no ssid (hidden networks perhaps?)

The errors still persists in the program.

@WesWeCan
Copy link
Author

WesWeCan commented Aug 18, 2021

I have tried to run the nmcli command via the node CLI, this seems where the error stems from:

error.txt

So via Bash the command seems to work as intended, but when done via a node environment it doesn't work.

@friedrith
Copy link
Owner

I see several possibilities:

  • node doesn't the same access as your user in the terminal
  • nmcli returns a none-zero error in the terminal
  • child_process has trouble on raspbian

I am currently working on a new version to stabilize these commands on linux. Can you follow these steps on your raspbian to use this new version currently in development:

  • git clone https://github.com/friedrith/node-wifi.git
  • npm install
  • node scripts/scan.js

Check if you have any good result or another fail.

@WesWeCan
Copy link
Author

This seems to work as I get the same list as mentioned earlier!

@friedrith
Copy link
Owner

friedrith commented Aug 18, 2021

Nice 👍 . I will publish a beta version using this new implementation very soon. I might ask you to test it to be sure it is solving your problem once integrating.

@WesWeCan
Copy link
Author

Ok! Thanks in advance. Hit me up when the beta is released.

I will test it with dhcpcd enabled, and disabled then.

@friedrith
Copy link
Owner

Hi, an alpha is available on npm. You can install it using the command: npm i [email protected]. Tell me if it is fixing your situation.

@WesWeCan
Copy link
Author

Thank you!

I have tested it. I will try to isolate the problem better soon.
It seems a production electron environment has something to do with it.
When serving a development build it seems to work now, but I get the same error message when when packaged.

I will research this further. I can imagine more people are trying to do the same.

@friedrith
Copy link
Owner

I didn't know you were using electron. Your issue may be caused by a path problem (cf https://stackoverflow.com/questions/45149031/electron-packager-spawn-enoent). Can you try the fix?

Electron also has several threads (main, renderer). Be sure to use the good thread (I guess it is main) otherwise it won't work.

@friedrith friedrith added the bug label Aug 26, 2021
@WesWeCan
Copy link
Author

Ok, I have tried a couple of different solutions. No luck so far in the past couple of weeks.
I keep getting the same error.

I have tried to change the process.env.PATH

The fix-path package didn't build, so I tried to recreate the fix from the source.

Do you have another insight maybe?

@friedrith
Copy link
Owner

friedrith commented Sep 12, 2021

From my experience, the best way to locate a problem is to split the situation into several pieces. First maybe you can isolate your code using node-wifi into a single file. Maybe could you try to run this code on the same hardware and OS but using node.js environment?

PS: don't hesitate to share your progress there so that we can iterate faster.

@lclnrd
Copy link

lclnrd commented Mar 1, 2022

Same behavior on Raspberry pi / Debian 11.6. Any update on this ?

@fosteman
Copy link

fosteman commented Sep 1, 2022

Issue still persists, any updates ?

I'm running my wlan0 in Master mode
wlan0 IEEE 802.11 Mode:Master Tx-Power=31 dBm Retry short limit:7 RTS thr:off Fragment thr:off Power Management:off

@fosteman
Copy link

fosteman commented Sep 1, 2022

Apparently, I have been lacking network-manager installed since I'm running on Armbian Lite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants