fix(installer): interactive fallback rejects an install root without its python suffix
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
scripts/install_api.py の124~136行にある対話型フォールバックを読み、次に提供された合成ハーネスを root-then-python、python-only、adjacent-valid に対して実行します。Issue では失われた結合パスを特定し、期待される .pth のターゲットとプロンプト回数を示しています。root の回答が1回のプロンプト後に成功し、両方の対照ケースで結果が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
When the installer cannot import from its existing adjacent python directory and prompts for another Binary Ninja install directory, entering an alternate install root leaves the path unchanged. The next validation checks the root instead of its python child and prompts again. Entering the child's full path works in the bounded fixture below. This affects the interactive recovery branch; a working adjacent API directory bypasses it.
Steps to reproduce
The following executed reproduction uses the unmodified installer source with synthetic install directories and a stub binaryninja module. It exercises the command-line entry point, directory guard, real validate_path, prompt loop, and .pth writing. It does not import a Binary Ninja native core or reproduce a licensed Binary Ninja installation.
- Save the Python harness below as
reproduce.pyoutside an installation. Supply the path to the installer source from either baseline listed under Runtime or environment; the harness copies it into a synthetic installation layout before execution. - Run
python3 -I -S reproduce.py SOURCE_INSTALL_API root-then-python. The initialoriginal/pythondirectory exists but is empty, so validation fails withModuleNotFoundError. The alternate installation has a stub module only underalternate/python. The first answer is the absolute alternate install root; the second is itspythonchild. - Run the
python-onlycontrol with the same command, replacing the final argument. It supplies the child immediately. Run theadjacent-validcontrol to put the stub under the original adjacent Python directory and avoid fallback entirely.
"""Exercise the unmodified installer with synthetic packages, never a native core.
Usage: python3 -I -S reproduce.py SOURCE_INSTALL_API CASE
CASE: root-then-python, python-only, adjacent-valid
"""
import builtins
import contextlib
import io
import json
from pathlib import Path
import runpy
import shutil
import site
import sys
import tempfile
source = Path(sys.argv[1]).resolve()
case = sys.argv[2]
assert case in {"root-then-python", "python-only", "adjacent-valid"}
with tempfile.TemporaryDirectory(prefix="installer-fixture-") as directory:
fixture = Path(directory)
original = fixture / "original"
alternate = fixture / "alternate"
destination = fixture / "site-packages"
(original / "scripts").mkdir(parents=True)
(original / "python").mkdir()
(alternate / "python").mkdir(parents=True)
destination.mkdir()
script = original / "scripts" / "install_api.py"
shutil.copyfile(source, script)
module = "def core_version():\n return 'synthetic-core-no-native-runtime'\n"
(alternate / "python" / "binaryninja.py").write_text(module)
if case == "adjacent-valid":
(original / "python" / "binaryninja.py").write_text(module)
answers = iter({
"root-then-python": [alternate, alternate / "python"],
"python-only": [alternate / "python"],
"adjacent-valid": [],
}[case])
prompts = []
def answer(prompt):
prompts.append(prompt)
print(prompt)
try:
value = str(next(answers))
except StopIteration:
raise AssertionError("unexpected extra installer prompt")
print(value)
return value
builtins.input = answer
site.getusersitepackages = lambda: str(destination)
site.getsitepackages = lambda: [str(destination)]
site.check_enableusersite = lambda: True
sys.argv = [str(script)]
output = io.StringIO()
with contextlib.redirect_stdout(output), contextlib.redirect_stderr(output):
runpy.run_path(str(script), run_name="__main__")
pth_lines = (destination / "binaryninja.pth").read_text().splitlines()
expected = original / "python" if case == "adjacent-valid" else alternate / "python"
assert pth_lines == [str(expected), str(expected) + str(sys.version_info.major)]
assert len(prompts) == {"root-then-python": 2, "python-only": 1, "adjacent-valid": 0}[case]
log = output.getvalue().replace(str(fixture), "<fixture>")
print(log, end="")
print(json.dumps({"case": case, "prompts": len(prompts), "pth_target": str(expected.relative_to(fixture)), "success": True}))
The harness redirects every site-packages destination into its temporary directory, and -I -S excludes existing site initialization and environment-provided import paths. It normalizes its temporary root to <fixture> in printed output. The stub returns a deliberately synthetic version string; it implements only the interface this installer validates.
Expected behavior
After reaching the interactive fallback, supplying an install root whose python child passes validation should select that child and finish without another path prompt. The prompt explicitly asks for the install directory, and the non-python branch attempts to append python. Supplying the child explicitly should continue to work, and an already valid adjacent Python directory should continue to bypass the fallback.
Actual behavior
The root-then-child case produced this result on both source baselines:
Found install folder of <fixture>/original/python
Binary Ninja not found: <fixture>/original/python
Please provide the path to Binary Ninja's install directory:
[<fixture>/original/python] :
<fixture>/alternate
Binary Ninja not found: <fixture>/alternate
Please provide the path to Binary Ninja's install directory:
[<fixture>/alternate] :
<fixture>/alternate/python
Found Binary Ninja core version: synthetic-core-no-native-runtime
Installing on user site: <fixture>/site-packages
Binary Ninja API installation success.
{"case": "root-then-python", "prompts": 2, "pth_target": "alternate/python", "success": true}
The development-source python-only control completed with one prompt and wrote both .pth entries pointing to the alternate Python directory and its Python-major-version companion. The adjacent-valid control completed with zero prompts and wrote the entries for the original Python directory. Two local runs of each reported case produced the same results. No runtime result for a real licensed installation is claimed.
Evidence
- Expected source: The pinned installer's prompt at
scripts/install_api.py:124asks for the install directory; its branch at lines 133–136 attempts to handle an answer without apythonsuffix. The earlier implementation visible in the refactoring PR under References assigned the joined path. - Failure source: The pinned installer at
scripts/install_api.py:133–136discards the return value ofos.path.join(new_path, "python")before assigningapi_path = new_path; the executed fixture transcript above shows the resulting second prompt. - Evidence provenance: observed
- Local verification: reproduced
- Reproduction completeness: incomplete
- Missing fact: An end-to-end run using licensed Binary Ninja installations, including an existing adjacent API directory that fails import and an alternate installation whose API can import in the same interpreter, was not performed. The fixture supplies those import conditions synthetically.
Restoration check
With the same fixture and initially failing adjacent directory, the root answer should complete installation after one prompt and write .pth entries for the alternate python directory, rather than validate the root and ask again. The explicit-child and valid-adjacent controls should retain their successful results. These signals test the same input contract without bypassing path validation.
Runtime or environment
Version and Platform (required):
- Binary Ninja version: latest published stable source
stable/6.0.10905, pinned installer; current default-branchdevsource, pinned installer. The installer files are byte-identical. - Edition: not applicable to the synthetic fixture; no licensed native runtime was used.
- OS: macOS.
- OS version: 27.2.
- CPU architecture: arm64.
- Python: CPython 3.15.2, launched with
-I -S.
No analysis binary, screenshot, or video is needed for this installer-only fixture. A missing initial adjacent directory does not reach the prompt: the earlier isdir guard returns first. The reproduction creates that directory deliberately and does not run the installer directly from a source checkout as though it were an installed product.
References
- Closed issue #5811 concerns running the script from a source clone and was resolved by directing the reporter to the installed copy. This report exercises the installed-layout fallback with an existing adjacent directory; it does not claim that a clone is a supported installation or that Free provides licensed API access.
- Merged refactoring PR #3809 contains the earlier joined-path assignment and the refactored fallback. Its virtual-environment problem is distinct from the root-answer normalization reported here.
Triage assessment
- Impact level: P2
- Assessment status: supported
- Impact basis: The executed fixture demonstrates a bounded failure of the interactive recovery input contract: an install root is rejected while its API child succeeds. The usual working adjacent path is unaffected in the control. Frequency in real licensed installations is unknown.
- Workaround status: available
- Workaround basis: Supplying the explicit
pythonchild succeeds and writes the expected.pthentries in the same fixture. Its use with a real installation still requires that installation's API to import successfully in the selected interpreter.
- 主要言語
- C++
- スター
- 1.3k
- フォーク
- 304
- 平均マージ
- 2日 20時間
- マージ済み PR(30日)
- 10
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Vector35/binaryninja-api のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
Vector35/binaryninja-api#8715 ·
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
Vector35/binaryninja-api#8713 ·
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
Vector35/binaryninja-api#8689 ·
メンテナーはふだん 2 日以内に返信
-
Component: Python API
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Vector35/binaryninja-api#8649 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Vector35/binaryninja-api#8621 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
Vector35/binaryninja-api の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
ESPresense/ESPresense#2680 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1時間未満 初心者へのやさしさ 75/100
stew675/llama-cpp-rdna-boosts#348 ·
メンテナーはふだん 1 日以内に返信
-
Documentation: Add comprehensive newcomer onboarding guide, project structure, and local usage to README対応中かも @Ash-Blanc が今日担当しました。 オープンarea/other status/bot-triaged status/need-triage
難易度 2/5 半日 初心者へのやさしさ 85/100
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信