Conversation
The daemon install command was failing in SSH sessions and other environments where XDG_RUNTIME_DIR is not set, causing systemctl --user commands to fail with "Failed to connect to bus". This fix: - Adds a helper method to create systemctl commands with proper XDG_RUNTIME_DIR environment variable - Automatically detects when the user's systemd session isn't running and enables linger via loginctl - Waits for the runtime directory to be created before proceeding - Provides clear error messages if the session cannot be started 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @AnnatarHe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request provides a critical fix for the daemon installation process on Linux, specifically addressing issues encountered in non-interactive sessions like SSH. By standardizing the handling of Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses the issue of systemctl --user commands failing in non-interactive environments like SSH by ensuring XDG_RUNTIME_DIR is properly set. The introduction of the systemctlUserCmd helper is a clean way to centralize this logic and has been applied consistently across the Linux daemon installer. The addition of ensureUserSystemdSession to automatically enable linger and wait for the user session is a robust solution to the underlying problem. The code is well-structured, and the changes are logical. I have one minor suggestion to improve maintainability regarding the use of named constants.
| for i := 0; i < 10; i++ { | ||
| time.Sleep(500 * time.Millisecond) |
There was a problem hiding this comment.
The retry count (10) and sleep interval (500ms) are hardcoded. It's a best practice to define such 'magic numbers' as named constants. This improves readability by giving them a meaningful name and makes them easier to find and modify in the future.
I'd recommend defining them at the package level, for example:
const (
runtimeDirCreationRetries = 10
runtimeDirCreationInterval = 500 * time.Millisecond
)Then, you can use these constants within your loop.
Summary
XDG_RUNTIME_DIRis not setsystemctlUserCmd()that properly setsXDG_RUNTIME_DIRenvironment variable for allsystemctl --usercommandsloginctl enable-lingerwhen the user's systemd session isn't runningProblem
When running
shelltime daemon installin an SSH session or other non-interactive environment, the command would fail with:This was because
systemctl --userrequiresXDG_RUNTIME_DIRto be set (typically/run/user/<uid>), which isn't available in certain session types.Test plan
go run cmd/cli/main.go daemon installgo build ./...🤖 Generated with Claude Code