fix(installer): interactive fallback rejects an install root without its python suffix
Maintainer antworten meist innerhalb von 2 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 78/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- python
- Bereich
- cli, developer-experience
Rechercherichtung
Lies scripts/install_api.py im Bereich des interaktiven Fallbacks in den Zeilen 124–136 und führe dann den bereitgestellten synthetischen Harness für root-then-python, python-only und adjacent-valid aus. Das Issue benennt den verlorenen zusammengefügten Pfad und gibt die erwarteten .pth-Ziele und die Anzahl der Eingabeaufforderungen an; die Aufgabe ist abgeschlossen, wenn eine Root-Antwort nach einer Eingabeaufforderung erfolgreich ist und beide Kontrollen ihre Ergebnisse beibehalten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- C++
- Sterne
- 1.3k
- Forks
- 304
- Ø Merge
- 2 T. 20 Std.
- Gemergte PRs (30 T.)
- 10
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Vector35/binaryninja-api
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100
Vector35/binaryninja-api#8715 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
Vector35/binaryninja-api#8713 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Vector35/binaryninja-api#8689 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Component: Python API
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Vector35/binaryninja-api#8649 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Hexagon lifting issuesOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Vector35/binaryninja-api#8621 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in Vector35/binaryninja-api
Ähnliche Issues
-
Bug Core VIF
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
ESPresense/ESPresense#2680 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 Unter einer Stunde Anfängerfreundlichkeit 75/100
stew675/llama-cpp-rdna-boosts#348 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Documentation: Add comprehensive newcomer onboarding guide, project structure, and local usage to READMEEvtl. vergeben @Ash-Blanc hat das heute übernommen. Offenarea/other status/bot-triaged status/need-triage
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 85/100
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag