Skip to content

fix: guard worktrunk init and globals - #758

Merged
shunkakinoki merged 1 commit into
mainfrom
fix/worktrunk-globals
Feb 7, 2026
Merged

fix: guard worktrunk init and globals#758
shunkakinoki merged 1 commit into
mainfrom
fix/worktrunk-globals

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Feb 7, 2026

Copy link
Copy Markdown
Owner

Changes\n- Guard worktrunk shell init across fish/bash/zsh\n- Ensure rustup stable toolchain for cargo globals\n- Export BUN_INSTALL via home session vars\n\n## Technical Details\n- Move worktrunk init to fish interactive shell after PATH setup\n- Run rustup toolchain install/default in cargo globals activation\n- Set BUN_INSTALL for consistent bun global paths\n\n## Testing\n- make build && make switch\n\nGenerated with GitHub Copilot CLI by GPT-5


Summary by cubic

Guarded Worktrunk shell initialization and hardened global toolchains to prevent shell errors and ensure consistent paths. Adds rustup stable toolchain for cargo globals and sets BUN_INSTALL for predictable bun installs.

  • Bug Fixes
    • bash/zsh: only run Worktrunk init if wt exists.
    • fish: run Worktrunk init after PATH setup and guard with type check.
    • cargo globals: add rustc to PATH; install and set rustup stable before activation.
    • npm globals: export BUN_INSTALL="$HOME/.bun" for consistent bun global paths.

Written for commit 5cbc1db. Summary will update on new commits.

Copilot AI review requested due to automatic review settings February 7, 2026 19:15
@shunkakinoki shunkakinoki added the bug Indicates an unexpected problem or unintended behavior. label Feb 7, 2026
@coderabbitai

coderabbitai Bot commented Feb 7, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added Rust compiler binaries to development environment PATH for improved toolchain access
    • Exposed BUN package manager installation path as a session-level environment variable
  • Improvements

    • Shell initialization now safely checks for tool availability before running, preventing errors when tools are unavailable

Walkthrough

Updates home-manager configurations to add defensive guards around optional tool initialization (Worktrunk/wt command) across multiple shells, while improving PATH and environment variable exposure for Rust and Bun development tools.

Changes

Cohort / File(s) Summary
Rust Tooling
home-manager/modules/cargo-globals/default.nix
Adds rustc to PATH, introduces dry-run rustup commands to install stable toolchain and set it as default.
Package Manager Env
home-manager/modules/npm-globals/default.nix
Exposes BUN_INSTALL as a session-level environment variable set to $HOME/.bun.
Shell Init Guards
home-manager/programs/bash/default.nix, home-manager/programs/fish/default.nix, home-manager/programs/zsh/default.nix
Adds conditional checks for wt command existence before executing Worktrunk shell initialization to prevent errors when tool is unavailable. Fish also relocates init from global to interactive shell scope.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

bug

Poem

🐰 A rabbit checks if tools exist before they play,
Adding guards to shells, the defensive way,
Rustc joins the path, Bun finds its home,
Safer initialization scripts, wherever they roam! 🛡️

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/worktrunk-globals

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @shunkakinoki, 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 enhances the robustness and consistency of the development environment setup. It achieves this by making worktrunk shell integration conditional across various shells, ensuring the correct Rust toolchain is active for global Cargo packages, and standardizing the BUN_INSTALL path. These changes aim to prevent errors in environments where certain tools might not be present and provide a more predictable setup for development tools.

Highlights

  • Shell Initialization Robustness: Conditionalized the worktrunk shell initialization across Bash, Fish, and Zsh to prevent errors if the wt command is not found, improving environment stability.
  • Rust Toolchain Management: Ensured the stable Rust toolchain is installed and set as default during cargo-globals activation, providing a consistent Rust development environment.
  • Bun Installation Path Configuration: Explicitly set the BUN_INSTALL environment variable in home session variables, standardizing the path for Bun global package management.
Changelog
  • home-manager/modules/cargo-globals/default.nix
    • Added rustc to the PATH environment variable.
    • Included commands to install and set the stable Rust toolchain using rustup during activation.
  • home-manager/modules/npm-globals/default.nix
    • Introduced BUN_INSTALL as a home session variable, setting its value to $HOME/.bun.
  • home-manager/programs/bash/default.nix
    • Wrapped the worktrunk shell initialization command with a check (if command -v wt) to ensure wt exists before execution.
  • home-manager/programs/fish/default.nix
    • Removed the unconditional worktrunk shell initialization from the initial block.
    • Re-added the worktrunk shell initialization within a conditional block (if type -q wt) after fish_add_path commands, ensuring wt is available and PATH is set.
  • home-manager/programs/zsh/default.nix
    • Wrapped the worktrunk shell initialization command with a check (if command -v wt) to ensure wt exists before execution.
Activity
  • No human activity has been recorded on this pull request since its creation.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@mesa-dot-dev

mesa-dot-dev Bot commented Feb 7, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@shunkakinoki
shunkakinoki enabled auto-merge (squash) February 7, 2026 19:16
@mesa-dot-dev

mesa-dot-dev Bot commented Feb 7, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Guarded worktrunk initialization and global environment variables across shells, ensuring rustup stable toolchain and consistent BUN_INSTALL paths.

What changed?

  • Guarded worktrunk shell init across fish/bash/zsh
  • Ensured rustup stable toolchain for cargo globals
  • Exported BUN_INSTALL via home session vars
  • Moved worktrunk init to fish interactive shell after PATH setup
  • Ran rustup toolchain install/default in cargo globals activation
  • Set BUN_INSTALL for consistent bun global paths

Description generated by Mesa. Update settings

@shunkakinoki
shunkakinoki disabled auto-merge February 7, 2026 19:16
@shunkakinoki
shunkakinoki merged commit 8bdb6aa into main Feb 7, 2026
29 of 31 checks passed
@shunkakinoki
shunkakinoki deleted the fix/worktrunk-globals branch February 7, 2026 19:16

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several good improvements for environment setup and robustness. It guards the worktrunk shell initialization across bash, fish, and zsh to prevent errors when the command is not present. It also ensures the stable rust toolchain is installed and set as the default during activation, and correctly exports BUN_INSTALL for consistent bun paths. The changes are logical and well-implemented. I have one suggestion to improve the PATH configuration for Rust to better align with the use of rustup and avoid potential toolchain conflicts.

Comment on lines +18 to 19
export PATH=${pkgs.rustup}/bin:${pkgs.cargo}/bin:${pkgs.rustc}/bin:${pkgs.dasel}/bin:${pkgs.jq}/bin:${pkgs.gcc}/bin:${pkgs.pkg-config}/bin:$PATH
export CARGO_HOME="$HOME/.cargo"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Since you're using rustup to manage toolchains, it's better to rely on it to provide the correct cargo and rustc binaries via its shims in $CARGO_HOME/bin. Explicitly adding ${pkgs.cargo}/bin and ${pkgs.rustc}/bin to the PATH can lead to conflicts between the nix-provided packages and the rustup-managed toolchain.

I suggest defining CARGO_HOME first and then adding its bin directory to the PATH, removing the direct dependencies on pkgs.cargo and pkgs.rustc from the PATH for this activation script.

    export CARGO_HOME="$HOME/.cargo"
    export PATH="$CARGO_HOME/bin:${pkgs.rustup}/bin:${pkgs.dasel}/bin:${pkgs.jq}/bin:${pkgs.gcc}/bin:${pkgs.pkg-config}/bin:$PATH

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens shell initialization and global tool setup in the home-manager configuration, aiming to prevent failures when optional tools aren’t installed and to make bun/cargo globals more consistent across shells.

Changes:

  • Guard wt config shell init … so shells don’t error when wt is absent (bash/zsh), and move fish init into interactive context after PATH setup.
  • Export BUN_INSTALL via home.sessionVariables to standardize bun global paths.
  • Add rustup “stable” toolchain install/default steps to the cargo globals activation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
home-manager/programs/zsh/default.nix Wrap worktrunk init in a wt presence check to avoid shell startup errors.
home-manager/programs/fish/default.nix Move worktrunk init to interactiveShellInit and guard it with type -q wt.
home-manager/programs/bash/default.nix Wrap worktrunk init in a wt presence check to avoid shell startup errors.
home-manager/modules/npm-globals/default.nix Add BUN_INSTALL to home.sessionVariables for consistent bun globals.
home-manager/modules/cargo-globals/default.nix Modify activation PATH and add rustup stable toolchain install/default steps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +18 to 22
export PATH=${pkgs.rustup}/bin:${pkgs.cargo}/bin:${pkgs.rustc}/bin:${pkgs.dasel}/bin:${pkgs.jq}/bin:${pkgs.gcc}/bin:${pkgs.pkg-config}/bin:$PATH
export CARGO_HOME="$HOME/.cargo"
$DRY_RUN_CMD ${pkgs.rustup}/bin/rustup toolchain install stable
$DRY_RUN_CMD ${pkgs.rustup}/bin/rustup default stable
export PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig${libiconvPkgConfigPath}''${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The activation script installs/sets a rustup toolchain (rustup toolchain install stable / rustup default stable), but the subsequent installs are performed with ${pkgs.cargo}/bin/cargo + ${pkgs.rustc}/bin/rustc from the PATH. That means these rustup commands don’t actually ensure the toolchain used for cargo install, while still introducing network/stateful side effects and a potential home-manager switch failure when offline.

Consider either (a) removing the rustup toolchain/default steps, or (b) explicitly running cargo via rustup (e.g., rustup run stable cargo … / setting RUSTUP_TOOLCHAIN=stable) and guarding the toolchain install so it’s idempotent and doesn’t hard-fail when the toolchain can’t be fetched.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Indicates an unexpected problem or unintended behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants