node-keytar
node-keytar copied to clipboard
docker compose Error: Cannot autolaunch D-Bus without X11 $DISPLAY
i run the node app in docker on win10 pro. Dockerfile:
FROM node:latest
COPY . /app
WORKDIR /app
RUN apt-get update && apt-get install -y libsecret-1-dev
RUN npm install
when i run the code
const token = await keytar.findPassword('xxx');
error:
(node:1) UnhandledPromiseRejectionWarning: Error: Cannot autolaunch D-Bus without X11 $DISPLAY
This is a generic error resulting from dbus not being ready for keytar to query.
I'm not familiar with how to setup a Docker container that will support keytar, but the mention of X11 might mean that it's expecting some sort of GUI to be ready. I'd look at also installing xvfb in your Dockerfile as that might be the trick to address this error and have D-Bus ready for you.
See a similar issues here and there.
See how it's solved when running on Travis CI where I run Electron-based app in e2e testing mode (source):
- | # init dbus
NO_AT_BRIDGE=1;
eval $(dbus-launch --sh-syntax);
- | # init keychain
eval $(echo -n "" | /usr/bin/gnome-keyring-daemon --login);
eval $(/usr/bin/gnome-keyring-daemon --components=secrets --start);
/usr/bin/python -c "import gnomekeyring;gnomekeyring.create_sync('login', '