Bug: Azure CLI extensions from Nix packages are not discoverable in devbox shell

オープン
#2,824 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go, python
領域
cli, devtools

調査の方向性

Start by tracing how Devbox configures package environments and launches commands in the shell, then inspect the Nix wrapper for az and how it handles PYTHONPATH. Reproduce with the listed azure-cli and extension packages and run az extension list; done means the declaratively installed extension is discovered in the Devbox shell.

索引モデルが issue の本文から書いたものです。

説明

bug p3 processed triage unrelated
What happened?

When managing azure-cli and its extensions declaratively in devbox.json, the az command is unable to discover the extensions, even though the package files are correctly installed in the Nix profile.

This seems to be caused by the Nix wrapper for the az executable, which appears to create an isolated Python environment, ignoring the PYTHONPATH from the parent devbox shell. This prevents the Azure CLI's standard site-packages auto-discovery from working.

This contrasts with other ecosystems like helm, where setting a HELM_PLUGINS environment variable works as expected. The equivalent AZURE_EXTENSION_DIR does not work here because the Nix package for the extension installs it as a Python module (azext_*) rather than in a separate directory structure.

Steps to reproduce
  1. Create a new directory and run devbox init.

  2. Set the devbox.json to the following content:

    {
      "packages": [
        "[email protected]",
        "[email protected]"
      ]
    }
    
  3. Start the shell with devbox shell.

  4. Run the command to list extensions:

    az extension list
    
  5. (Optional) Confirm the extension's files are present in the environment's site-packages:

    # Path may vary slightly based on python version
    ls .devbox/nix/profile/default/lib/python3.13/site-packages/
    

This will show azext_log_analytics_solution@ and other related files, proving the package was installed by Devbox.

Expected behavior

The az extension list command should discover and list the log-analytics-solution extension, similar to this output:

Name                      Version     State     Type
-----------------------  ---------  --------  ------
log-analytics-solution   1.0.1        Enabled  whl
Actual behavior

The az extension list command returns an empty list, and commands provided by the extension (e.g., az log-analytics-solution) are not found.

Analysis of the Cause

Debug logs from az extension list --debug show that the CLI never attempts to load extensions from any directory (~/.azure/cliextensions, site-packages, or a path from AZURE_EXTENSION_DIR). It seems the Nix wrapper script for az sanitizes the PYTHONPATH, breaking the auto-discovery mechanism that relies on finding azext_* modules.

Workaround

The current pragmatic workaround is to abandon the declarative management of extensions and use the imperative approach:

  1. Only include the core azure-cli in devbox.json.

    { "packages": ["[email protected]"] }
    
  2. Inside the devbox shell, manually install the extension.

    az extension add --name log-analytics-solution
    

This works because it installs the extension into ~/.azure/cliextensions, a path the az wrapper knows how to check.

Command

No response

devbox.json
{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.17.1/.schema/devbox.schema.json",
  "packages": [
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]"
  ],
  "shell": {
    "init_hook": [
      "export SOPS_AGE_KEY_FILE=$(pwd)/.age.agekey"
    ]
  }
}
Devbox version

0.17.1

Nix version

nix (Determinate Nix 3.17.3) 2.33.3

What system does this bug occur on?

macOS (Apple Silicon)

Debug logs

No response

主要言語
Go
スター
12.4k
フォーク
358
平均マージ
17時間 12分
マージ済み PR(30日)
31

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

jetify-com/devbox のほかの issue

jetify-com/devbox の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。