-
Notifications
You must be signed in to change notification settings - Fork 0
fix: use tomlq to parse dependency-groups.tools in uv-globals #1368
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
Changes from all commits
491fc9e
aceae15
980e697
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,40 +8,31 @@ if ! timeout 3 bash -c 'exec 3<>/dev/tcp/1.1.1.1/53' 2>/dev/null; then | |||||||||||||
| exit 0 | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| # Install uv global tools from pyproject.toml | ||||||||||||||
| # Reads dependencies from ~/dotfiles/pyproject.toml and installs them as global tools | ||||||||||||||
|
|
||||||||||||||
| PYPROJECT="${HOME}/dotfiles/pyproject.toml" | ||||||||||||||
|
|
||||||||||||||
| # Exit if no pyproject.toml exists | ||||||||||||||
| if [ ! -f "$PYPROJECT" ]; then | ||||||||||||||
| echo "No ${PYPROJECT} found, skipping uv globals install" | ||||||||||||||
| exit 0 | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| # Check for required tools | ||||||||||||||
| if ! command -v uv &>/dev/null; then | ||||||||||||||
| echo "uv not found, skipping uv globals install" | ||||||||||||||
| exit 0 | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| if ! command -v dasel &>/dev/null; then | ||||||||||||||
| echo "dasel not found, skipping uv globals install" | ||||||||||||||
| exit 0 | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| if ! command -v jq &>/dev/null; then | ||||||||||||||
| echo "jq not found, skipping uv globals install" | ||||||||||||||
| if ! command -v tomlq &>/dev/null; then | ||||||||||||||
| echo "tomlq not found, skipping uv globals install" | ||||||||||||||
| exit 0 | ||||||||||||||
|
Comment on lines
+23
to
25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
# Verify the runtime check in installer/spec:
rg -n 'command -v tomlq|tomlq' home-manager/modules/uv-globals/install-uv-globals.sh spec/uv_globals_spec.sh
# Verify PATH/exported tools for uv-globals module:
rg -n 'export PATH=' home-manager/modules/uv-globals/default.nix
rg -n 'tomlq|dasel|jq' home-manager/modules/uv-globals/default.nixRepository: shunkakinoki/dotfiles Length of output: 933 🏁 Script executed: # Check if tomlq is referenced elsewhere in default.nix or related files
rg -n 'tomlq|pkgs.toml' home-manager/modules/uv-globals/default.nix
# Also check if there are other related nix files
fd -e nix home-manager/modules/uv-globals/ -exec rg -l 'tomlq' {} \;Repository: shunkakinoki/dotfiles Length of output: 303 🏁 Script executed: # Check if tomlq is referenced anywhere in the nix module files
rg -n 'tomlq' home-manager/modules/uv-globals/
# Also check the full default.nix to see buildInputs/dependencies
cat -n home-manager/modules/uv-globals/default.nixRepository: shunkakinoki/dotfiles Length of output: 909 🏁 Script executed: export PATH=${pkgs.uv}/bin:${pkgs.dasel}/bin:${pkgs.jq}/bin:${pkgs.tomlq}/bin:$PATHRepository: shunkakinoki/dotfiles Length of output: 178
Line 23 hard-requires Add 🤖 Prompt for AI Agents |
||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| # Install uv global tools from pyproject.toml | ||||||||||||||
| # Reads dependencies from ~/dotfiles/pyproject.toml and installs them as global tools | ||||||||||||||
| echo "Installing uv global tools from pyproject.toml..." | ||||||||||||||
|
|
||||||||||||||
| # Parse Python version from requires-python (e.g., ">=3.13" -> "3.13") | ||||||||||||||
| PYTHON_VERSION=$(dasel -f "$PYPROJECT" -r toml 'project.requires-python' 2>/dev/null | sed 's/[^0-9.]//g' || echo "3.13") | ||||||||||||||
| PYTHON_VERSION=$(tomlq -r '.project["requires-python"]' "$PYPROJECT" 2>/dev/null | sed 's/[^0-9.]//g') | ||||||||||||||
| PYTHON_VERSION=${PYTHON_VERSION:-3.13} | ||||||||||||||
|
|
||||||||||||||
| # Parse dependencies from standard pyproject.toml format | ||||||||||||||
| DEPS=$(dasel -f "$PYPROJECT" -r toml -w json 'project.dependencies' 2>/dev/null | jq -r '.[]' 2>/dev/null || true) | ||||||||||||||
| DEPS=$(tomlq -r '.["dependency-groups"].tools[]' "$PYPROJECT" 2>/dev/null) | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the script uses set -e, if tomlq fails (for example, if the dependency-groups key is missing from pyproject.toml), the script will exit immediately with a non-zero status. This bypasses the graceful check on line 34. Adding || true ensures the script continues so it can handle the empty result gracefully, adhering to the principle of handling failures without blocking execution.
Suggested change
References
|
||||||||||||||
| DEPS=$(tomlq -r '.["dependency-groups"].tools[]' "$PYPROJECT" 2>/dev/null) | |
| DEPS=$(tomlq -r '.["dependency-groups"]?.tools? // [] | .[]?' "$PYPROJECT" 2>/dev/null || true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Guard the tomlq extraction against missing dependency-groups.tools; otherwise set -e can terminate the script before the empty-deps check runs.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/modules/uv-globals/install-uv-globals.sh, line 32:
<comment>Guard the `tomlq` extraction against missing `dependency-groups.tools`; otherwise `set -e` can terminate the script before the empty-deps check runs.</comment>
<file context>
@@ -8,40 +8,28 @@ if ! timeout 3 bash -c 'exec 3<>/dev/tcp/1.1.1.1/53' 2>/dev/null; then
-
-# Parse dependencies from standard pyproject.toml format
-DEPS=$(dasel -f "$PYPROJECT" -r toml -w json 'project.dependencies' 2>/dev/null | jq -r '.[]' 2>/dev/null || true)
+DEPS=$(tomlq -r '.["dependency-groups"].tools[]' "$PYPROJECT" 2>/dev/null)
if [ -z "$DEPS" ]; then
</file context>
| DEPS=$(tomlq -r '.["dependency-groups"].tools[]' "$PYPROJECT" 2>/dev/null) | |
| DEPS=$(tomlq -r '.["dependency-groups"].tools[]?' "$PYPROJECT" 2>/dev/null || true) |
Copilot
AI
Apr 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message is now misleading because the script no longer looks for general dependencies; it specifically reads dependency-groups.tools. Suggest updating the message to reflect the actual source (e.g., 'No dependency-groups.tools entries found in pyproject.toml') so failures are easier to diagnose.
| echo "No dependencies found in pyproject.toml" | |
| echo "No dependency-groups.tools entries found in pyproject.toml" |
Copilot
AI
Apr 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Piping via echo is less robust than printf because echo can treat leading -n/-e-like content as options and can be implementation-dependent. Prefer printf '%s\n' \"$DEPS\" | while ... (or, even better, avoid storing the whole list and stream directly from tomlq) to make the loop resilient to unusual dependency strings.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,14 +29,9 @@ When run bash -c "grep 'command -v uv' '$SCRIPT'" | |||||||||
| The output should include 'uv' | ||||||||||
| End | ||||||||||
|
|
||||||||||
| It 'checks for dasel command' | ||||||||||
| When run bash -c "grep 'command -v dasel' '$SCRIPT'" | ||||||||||
| The output should include 'dasel' | ||||||||||
| End | ||||||||||
|
|
||||||||||
| It 'checks for jq command' | ||||||||||
| When run bash -c "grep 'command -v jq' '$SCRIPT'" | ||||||||||
| The output should include 'jq' | ||||||||||
| It 'checks for tomlq command' | ||||||||||
| When run bash -c "grep 'command -v tomlq' '$SCRIPT'" | ||||||||||
| The output should include 'tomlq' | ||||||||||
| End | ||||||||||
| End | ||||||||||
|
|
||||||||||
|
|
@@ -60,9 +55,9 @@ End | |||||||||
| End | ||||||||||
|
|
||||||||||
| Describe 'tool installation' | ||||||||||
| It 'uses dasel to parse TOML' | ||||||||||
| When run bash -c "grep 'dasel' '$SCRIPT'" | ||||||||||
| The output should include 'dasel' | ||||||||||
| It 'uses tomlq to parse TOML' | ||||||||||
| When run bash -c "grep 'tomlq' '$SCRIPT'" | ||||||||||
| The output should include 'tomlq' | ||||||||||
| End | ||||||||||
|
|
||||||||||
| It 'uses uv tool install' | ||||||||||
|
|
@@ -75,9 +70,19 @@ When run bash -c "grep -- '--force' '$SCRIPT'" | |||||||||
| The output should include '--force' | ||||||||||
| End | ||||||||||
|
|
||||||||||
| It 'parses project.dependencies' | ||||||||||
| When run bash -c "grep 'project.dependencies' '$SCRIPT'" | ||||||||||
| The output should include 'project.dependencies' | ||||||||||
| It 'parses dependency-groups.tools' | ||||||||||
| When run bash -c "grep 'dependency-groups' '$SCRIPT'" | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The spec claims to verify Prompt for AI agents |
||||||||||
| The output should include 'dependency-groups' | ||||||||||
|
Comment on lines
+74
to
+75
|
||||||||||
| When run bash -c "grep 'dependency-groups' '$SCRIPT'" | |
| The output should include 'dependency-groups' | |
| When run bash -c "grep -E '\\[\"dependency-groups\"\\]\\.tools|dependency-groups\\.tools' '$SCRIPT'" | |
| The output should include '.tools' |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P0:
tomlqis not provisioned in the Nix module.home-manager/modules/uv-globals/default.nixonly exportsuv,dasel, andjqtoPATH. Sincetomlqis never onPATH,command -v tomlqwill always fail and the script will silently skip execution every time. Add${pkgs.tomlq}/binto thePATHexport indefault.nix.Prompt for AI agents