VS Code (code-oss) + GitHub Copilot

I think sharing this is helpful for somebody in this community.
I could manage to use GitHub Copilot with FreeBSD's VS Code (code-oss) and it seems to be running OK so far.
It took a few days to completely make it run, and I could reproduce it with my another desktop today.
I assume you are already signed up with GitHub Copilot (first month free).
  1. Run your desktop key chain or key ring correctly. In my case, I use KDE and kwallet was not running. So, I had to enable it by following https://wiki.archlinux.org/title/KDE_Wallet. Note you have to replace /etc/pam.d/sddm with /usr/local/etc/pam.d/sddm on FreeBSD. Also, as the following lines were commented out on mine, you have to comment them in by deleting # from the lines.
    Code:
    auth            optional        pam_kwallet5.so
    session         optional        pam_kwallet5.so auto_start
    Log out and in and make sure kwallet is running.
  2. Check /tmp/dbus-* with ls /tmp/dbus-*. In my case, I had three entries (sockets) like:
    Code:
    /tmp/dbus-UvMBE3Dh9z
    /tmp/dbus-XIGa1tUJrs
    /tmp/dbus-yyczZZQ7bP
    and you'll have to use one of them later. The most embrassing thing here is "I don't know which one to choose." Please let me know if you know a good way to choose one.
  3. Install VSCode from a package like:
    Code:
    # pkg install vscode
  4. Install GitHub Copilot. You may need to download a vsix file from https://marketplace.visualstudio.com/items?itemName=GitHub.copilot (click Download Extensions). Always choose the latest one. Manually install the vsix file by following https://bitwornhat.com/posts/code-oss-and-copilot .
  5. Create the following sh file vscode-copilot.sh and replace dbus-UvMBE3Dh9z with one of yours in 2.
    Code:
    #!/bin/sh
    export DBUS_SESSION_BUS_ADDRESS=unix:path=/tmp/dbus-UvMBE3Dh9z
    code-oss --verbose --enable-proposed-api GitHub.copilot
    chmod a+x vscode-copilot.sh and run it. If you see an error like "bus.c Failed to connect...." in the verbose message, then change dbus-XXXX to others. Try until you don't get the error.
  6. Now you will be asked to sign in to GitHub. Follow it and see if you don't get an error message like "You're running in a KDE environment but OS keyring is not available for encryption...." If you get the error, change dbus-XXXX to others.
  7. Make sure your Copilot is active by clicking the icon at the bottom right. If it's active, then your Copilot is supposed to be running!
This is it. I don't know if it works to everybody but hope it does to many FreeBSD users.
 
I think this will be a better solution for finding a dbus socket....

vscode-copilot.sh:
Code:
#!/bin/sh

DBUS_SOCK=`sockstat | grep kwalletd5 | grep -m1 /tmp/dbus | awk '{print $7}'`
export DBUS_SESSION_BUS_ADDRESS=unix:path=$DBUS_SOCK
code-oss --verbose --enable-proposed-api GitHub.copilot

Replace kwalletd5 with something else for GNOME, etc.
I guess the unix socket code-oss connects to is the one used by kwallet.
The above sh finds it and sets as DBUS_SOCK.

Note you can remove --verbose option from code-oss if you don't need verbose messages.
 
Back
Top