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

dbus session error when installing code server tunnel as service #7778

Closed
DanteOz opened this issue Dec 31, 2022 · 6 comments · Fixed by microsoft/vscode#185385
Closed

dbus session error when installing code server tunnel as service #7778

DanteOz opened this issue Dec 31, 2022 · 6 comments · Fixed by microsoft/vscode#185385
Assignees
Labels
code-server Issues on the VS Code Server.

Comments

@DanteOz
Copy link

DanteOz commented Dec 31, 2022

  • VSCode Version: Visual Studio Code CLI 1.74.2 (e8a3071ea4344d9d48ef8a4df2c097372b0c5161)

  • Local OS Version: Mac OS 13.0.1 (22A400)

  • Remote OS Version: Ubuntu 22.04.1

  • Remote Extension/Connection Type: Code-Server

  • Logs:

$ code tunnel service install
*
* Visual Studio Code Server
*
* By using the software, you agree to
* the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
* the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
*
[2022-12-31 17:47:14] error error creating dbus session: I/O error: No such file or directory (os error 2)

Steps to Reproduce:

  1. Install x64 VSCode CLI from https://code.visualstudio.com/#alt-downloads
  2. Move CLI executable to /usr/local/bin/code
  3. Run code tunnel service install

Does this issue occur when you try this locally?: No
Does this issue occur when you try this locally and all extensions are disabled?: No

@github-actions github-actions bot added the code-server Issues on the VS Code Server. label Jan 1, 2023
@kensteele
Copy link

I ran into the same issue attempting to install the tunnel service on Debian 10 on a Tinkerboard (arm64), but found a workaround.

  • strace code tunnel service install showed me it was failing to connect to /run/user/1000/bus:

connect(9, {sa_family=AF_UNIX, sun_path="/run/user/1000/bus"}, 21) = -1 ENOENT (No such file or directory)

  • Running systemctl --user start dbus enabled the /run/user/1000/bus socket.
  • Attempting to run code tunnel service install showed that it connected to the dbus socket, but failed to launch the service, however it successfully wrote the code-tunnel.service systemd file to ~/.vscode-cli/
  • From here, edit ~/.vscode-cli/code-tunnel.service and add User and Group entries to run as a specific user.

Example code-tunnel.service:

[Unit]
Description=Visual Studio Code Tunnel
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
User=ken
Group=ken
Restart=always
RestartSec=10
ExecStart=/usr/local/bin/code "--verbose" "--cli-data-dir" "/home/ken/.vscode-cli" "tunnel" "service" "internal-run"

[Install]
WantedBy=multi-user.target
  • Copy code-tunnel.service to the systemd path:
sudo cp ~/.vscode-cli/code-tunnel.service /etc/systemd/system/
  • Enable the and start code-tunnel service:
sudo systemctl daemon-reload
sudo systemctl enable code-tunnel.service
sudo systemctl start code-tunnel.service
  • At this point you should be able to connect to your tunnel remotely.

Hope this helps!

@amardeep
Copy link

amardeep commented Jan 7, 2023

My issue is different from original poster, but similar to previous comment. Running service install did write code-tunnel.service file but gave an error

error starting service: org.freedesktop.systemd1.NoSuchUnit: Unit code-tunnel.service not found

In my case, it worked after running:

systemctl --user daemon-reload
systemctl --user start code-tunnel

@realTaki
Copy link

realTaki commented Feb 9, 2023

I have the same quetion in code-cli version 1.75.0 (commit e2816fe719a4026ffa1ee0189dc89bdfdbafb164)

@majorthorn
Copy link

majorthorn commented Feb 16, 2023

I have the same issue. Throws this error regardless of being in home directory or /usr/local/bin or /usr/bin. This command worked once or twice as root but I wanted to make a dedicated user for this to run under. Since then I haven't be able to get it working. I have created and destroyed multiple Ubuntu 22.04 LXC/CT containers in proxmox and still have this issue.

The tunnel starts up just fine with code tunnel. The only issue is code tunnel service install

@jpawlowski
Copy link

jpawlowski commented Feb 25, 2023

Installing dbus-user-session package and a reboot resolved this issue on my LXC container:

sudo apt install dbus-user-session
sudo reboot

After rebooting the container, the service was successfully installed in user context.

username@containername:~$ code tunnel service install
To grant access to the server, please log into https://github.com/login/device and use code XXXX-XXXX

[2023-02-25 15:03:05] info Successfully registered service...
[2023-02-25 15:03:05] info Successfully enabled unit files...
[2023-02-25 15:03:05] info Tunnel service successfully started
Service successfully installed! You can use code tunnel service log to monitor it, and code tunnel service uninstall to remove it.

However, what I noticed is that this service would only auto-start when logged in to that host/container.

Enabling user lingering compensates this:

sudo loginctl enable-linger username

@connor4312
Copy link
Member

Thanks for all the reports and steps here! I've made the error much more helpful in this case.

For when the dbus connection fails (WSL section is only printed when running the CLI on WSL):

image

If the user is connected via SSH, then I print @jpawlowski's tip too after the service is installed:

image

connor4312 added a commit to microsoft/vscode that referenced this issue Jun 16, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jul 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
code-server Issues on the VS Code Server.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants