I managed to mostly solve it. I needed to install GPG >2.4 and pinentry-curses because the one that comes with Debian doesn’t appear to support keybox or something like that. It also sets the pin entry to curses in the config. It might work out of the box in Cursor just like it does in VS Code if you use one of the recent Ubuntu images since those come with 2.4.X pre-installed.
If, when running gpg --list-keys
(or other gpg operations) on the container you get a message about a lock such as,
gpg: Note: database_open 134217901 waiting for lock (held by 6520)
then run
rm ~/.gnupg/public-keys.d/pubring.db.lock.
Do that again in case it happens again. Probably shouldn’t as long as you don’t run more than one container or access the keyring from more than one system. I tried copying the kbx files instead of mounting them, but I didn’t manage to make it work.
When you’re running the container for the first time, committing directly from Cursor VCS panel won’t work. To solve, commit from the integrated terminal and enter your passphrase there. Then you should be able to commit from the editor and from the terminal.
This looks like an unpleasant workaround with possible security considerations as I’m not very well versed in how GPG works (is it safe to mount the whole .gnupg
dir?), so use at your own risk. I hope you’ll find it useful until the Cursor team manages to bring their Dev Container extension up to par with the VSC extension.
Here’s my .devcontainer
file that should install the fresher version of GPG from the testing
Debian package repository, mount the .gnupg
directory and write the settings to use curses and allow loopback for pin entry, so all you’d need to do is commit from the terminal to save your passphrase for your secret key and maybe delete the lock file.
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node",
"features": {
"ghcr.io/devcontainers/features/git-lfs:1": {
"autoPull": true,
"version": "latest"
},
"ghcr.io/devcontainers/features/github-cli:1": {
"installDirectlyFromGitHubRelease": true,
"version": "latest"
}
},
"runArgs": [
"--volume=${localEnv:HOME}/.gnupg:/home/node/.gnupg"
],
"postCreateCommand": [
"bash",
"-c",
"set -e && echo 'Installing GPG 2.4 and pinentry from Debian testing...' && echo 'deb http://deb.debian.org/debian testing main' | sudo tee /etc/apt/sources.list.d/testing.list > /dev/null && echo 'Package: gnupg gnupg2 gpg gpg-agent dirmngr keyboxd pinentry-curses\nPin: release a=testing\nPin-Priority: 500\n\nPackage: *\nPin: release a=stable\nPin-Priority: 900' | sudo tee /etc/apt/preferences.d/gnupg-testing > /dev/null && sudo apt update -qq && sudo apt install -t testing gnupg2 pinentry-curses -y -qq && echo 'pinentry-program /usr/bin/pinentry-curses' >> ~/.gnupg/gpg-agent.conf && echo 'allow-loopback-pinentry' >> ~/.gnupg/gpg-agent.conf && echo 'pinentry-mode loopback' >> ~/.gnupg/gpg.conf && echo 'GPG setup completed'"
]
}
Sorry if I posted in the wrong thread, but it was the only open and relevant one and I didn’t want to create a new topic.