Skip to content
New issue

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

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

Already on GitHub? # to your account

espruino doesn't detect anything on Arch Linux #182

Closed
goffi-contrib opened this issue Feb 5, 2025 · 6 comments
Closed

espruino doesn't detect anything on Arch Linux #182

goffi-contrib opened this issue Feb 5, 2025 · 6 comments

Comments

@goffi-contrib
Copy link

goffi-contrib commented Feb 5, 2025

Hello,

I've tried to use espruino tools installed from npm (11.0.0) on Arch Linux, and nothing is detected when using espruino --list (I have a brand new bangle.js 2 bought at FOSDEM).

It's working fine with Chromium using the App Loader, and it's detected without problem by my OS.

espruino use noble which is unmaintained (for 7 years!). There's @abandonware/noble which is in better shape, but no more luck with it. Anyway, it would be good to use another, maintained, dependency.

Thanks!

@gfwilliams
Copy link
Member

What happens if you run with --verbose? Does it give you any more info?

I was pretty sure that the Espruino package did install @abandonware/noble and not just normal noble - eg. https://github.com/espruino/EspruinoTools/blob/master/package.json#L31

Did you run:

sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

beforehand to ensure that Node.js had the relevant permissions to access the BLE stack?

@goffi-contrib
Copy link
Author

goffi-contrib commented Feb 5, 2025

Thanks for the quick answer!

My bad, indeed @abandonware/noble is used, I based my assumption on the doc, not on package.json.

Yes, I did run the setcap command.

Here are the logs:

% espruino --list --verbose         
0.1.57
Espruino Command-line Tool 0.1.57
-----------------------------------

Acorn library not found - you'll need it for compiled code
Found /usr/lib/node_modules/espruino/libs/targz.js
Found /usr/lib/node_modules/espruino/libs/utf8.js
Found /usr/lib/node_modules/espruino/libs/webrtc-connection.js
webrtc-connection: require("peerjs-on-node") failed:  Error: Cannot find module 'peerjs-on-node'
Require stack:
- /usr/lib/node_modules/espruino/index.js
- /usr/lib/node_modules/espruino/bin/espruino-cli.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1241:15)
    at Function._load (node:internal/modules/cjs/loader:1066:27)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
    at Module.require (node:internal/modules/cjs/loader:1327:12)
    at require (node:internal/modules/helpers:136:16)
    at eval (eval at loadJS (/usr/lib/node_modules/espruino/index.js:14:9), <anonymous>:88:14)
    at loadJS (/usr/lib/node_modules/espruino/index.js:14:9)
    at loadDir (/usr/lib/node_modules/espruino/index.js:29:7)
    at Object.init (/usr/lib/node_modules/espruino/index.js:82:3) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/lib/node_modules/espruino/index.js',
    '/usr/lib/node_modules/espruino/bin/espruino-cli.js'
  ]
}
webrtc-connection: Peer.js not loaded - Remote Connection disabled
ERROR No Peer.js implementation available while loading /usr/lib/node_modules/espruino/libs/webrtc-connection.js
Found /usr/lib/node_modules/espruino/libs/esprima/escodegen.js
Found /usr/lib/node_modules/espruino/libs/esprima/esmangle.js
Found /usr/lib/node_modules/espruino/libs/esprima/esprima.js
Found /usr/lib/node_modules/espruino/espruino.js
Found /usr/lib/node_modules/espruino/core/codeWriter.js
Found /usr/lib/node_modules/espruino/core/config.js
Found /usr/lib/node_modules/espruino/core/env.js
Found /usr/lib/node_modules/espruino/core/flasher.js
Found /usr/lib/node_modules/espruino/core/flasherESP8266.js
Found /usr/lib/node_modules/espruino/core/modules.js
Found /usr/lib/node_modules/espruino/core/notifications.js
Found /usr/lib/node_modules/espruino/core/serial.js
Found /usr/lib/node_modules/espruino/core/serial_chrome_serial.js
No chrome.serial - Chrome Serial disabled
Found /usr/lib/node_modules/espruino/core/serial_chrome_socket.js
No chrome.sockets - Chrome Socket disabled
Found /usr/lib/node_modules/espruino/core/serial_frame.js
serial_frame: Not running in a browser
Found /usr/lib/node_modules/espruino/core/serial_noble.js
Found /usr/lib/node_modules/espruino/core/serial_node_serial.js
Found /usr/lib/node_modules/espruino/core/serial_node_socket.js
Found /usr/lib/node_modules/espruino/core/serial_web_audio.js
Found /usr/lib/node_modules/espruino/core/serial_web_bluetooth.js
Found /usr/lib/node_modules/espruino/core/serial_web_serial.js
Found /usr/lib/node_modules/espruino/core/serial_webrtc.js
libs/webrtc-connection.js not loaded - Remote Connection disabled
Found /usr/lib/node_modules/espruino/core/serial_websocket_local.js
Found /usr/lib/node_modules/espruino/core/serial_websocket_relay.js
WebSocket relay support enabled
Found /usr/lib/node_modules/espruino/core/terminal.js
Found /usr/lib/node_modules/espruino/core/utils.js
Found /usr/lib/node_modules/espruino/plugins/assembler.js
Found /usr/lib/node_modules/espruino/plugins/boardJSON.js
Found /usr/lib/node_modules/espruino/plugins/compiler.js
Found /usr/lib/node_modules/espruino/plugins/getGitHub.js
Found /usr/lib/node_modules/espruino/plugins/localModules.js
Found /usr/lib/node_modules/espruino/plugins/minify.js
Found /usr/lib/node_modules/espruino/plugins/pretokenise.js
Found /usr/lib/node_modules/espruino/plugins/saveOnSend.js
Found /usr/lib/node_modules/espruino/plugins/setTime.js
Found /usr/lib/node_modules/espruino/plugins/unicode.js
UTF8 Library loaded successfully
Found /usr/lib/node_modules/espruino/plugins/versionChecker.js
Initialising CodeWriter
Initialising Config
Initialising Env
Initialising Flasher
Initialising FlasherESP8266
Initialising Modules
Initialising Notifications
Initialising Serial
  - Initialising Serial Noble Bluetooth LE
  - Initialising Serial Node Serial
  - Initialising Serial Node Socket
  - Initialising Serial Web Audio
  - Initialising Serial Web Bluetooth
  - Initialising Serial Web Serial
  - Initialising Serial Websocket Relay
Initialising SerialWebSocketRelay
Initialising Utils
Initialising Status
Initialising Assembler
Initialising BoardJSON
Initialising Compiler
Initialising GetGitHub
Initialising LocalModules
Initialising Minify
Initialising Unicode
Initialising VersionChecker
Initialising CoreModules
Initialising Pretokenise
Initialising SaveOnSend
Initialising SetTime
Searching for serial ports...
Noble: getPorts - initialising...
Noble: getPorts - initialising...
Noble: getPorts - initialising...
Noble: getPorts - initialising...
Noble: getPorts - initialising...
Noble: getPorts - initialising...
Noble: getPorts - initialising...
Error: No Ports Found

@gfwilliams
Copy link
Member

gfwilliams commented Feb 5, 2025

Ok, thanks - it looks from Noble: getPorts - initialising... like for some reason Noble isn't working. Usually there would be a Noble: stateChange message there which showed it was all working ok.

I'd be pretty sure that the Noble library is just broken again - If you tried some basic code I bet that is broken too: https://github.com/abandonware/noble?tab=readme-ov-file#quick-start-example

Which version of Node.js are you on? For some reason Noble has always been a bit flakey. I've just tried it here with Node v22 on Ubuntu 24 and it seems broken again.

I'll see about trying to use node-ble which maybe won't be quite as broken - until then you can try https://github.com/espruino/EspruinoTools?tab=readme-ov-file#web-ide-remote-connection

@gfwilliams
Copy link
Member

Just FYI this looks related: abandonware/noble#345

So a new version of node-bluetooth-hci-socket (not on NPM yet) might fix it, so npm i https://github.com/abandonware/node-bluetooth-hci-socket might work but on the system I tried the installation failed

@gfwilliams
Copy link
Member

Can you try reinstalling from NPM and see if that fixes it? Turns out we already had a node-ble backend but I'd disabled it because it broke quite a lot of stuff (but I think I managed to fix that now)

@goffi-contrib
Copy link
Author

Yes, it works now after reinstalling npm. For the record I'm using node v23.4.0. Thanks a lot for your quick feedback and fixes. I'm closing the issue.

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

No branches or pull requests

2 participants