`skip android build`: `--show-bin-path` result read from merged stdout+stderr, so a SwiftPM deprecation warning can be used as the bin path

Aperta Adatta ai principianti
#763 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
android, swift
Ambito
build-system

Direzione di ricerca

Leggi skipstone/Sources/SkipBuild/Commands/AndroidCommand.swift intorno alla ricerca di binPathCmd e all’helper captureLine di AndroidTestCommand.swift. Verifica come launchTool gestisce stderr per le chiamate con --show-bin-path, quindi esegui il flusso di compilazione o test Android pertinente con l’avviso di deprecazione di SwiftPM presente. Il lavoro è concluso quando il percorso bin viene preso da stdout e l’avviso non può far sì che la compilazione usi una directory di output non valida.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

skip android build (via the Gradle buildAndroidSwiftPackage… step) determines the .so output directory by running swift build --show-bin-path … --build-system native and taking the last non-empty line of the output. That output is read through launchTool(...), which defaults to includeStdErr: true, so stdout and stderr are merged.

SwiftPM prints a deprecation warning on stderr for --build-system native:

warning: '--build-system native' has been deprecated and will be removed in a future release; please report an issue at https://github.com/swiftlang/swift-package-manager/issues if you are unable to adopt the default build system.

When that stderr line happens to arrive after the stdout path line, lines.last is the warning sentence, Skip uses it as buildOutputFolder, and the build then fails trying to open it (NSCocoaErrorDomain Code=260, file not found). It is an ordering race: the same commit passes and fails on consecutive runs with the same warning present.

Where

  • skipstone/Sources/SkipBuild/Commands/AndroidCommand.swift (~L986–1016 on main @ 1.9.21): binPathCmd → launchTool(swiftCmd, arguments:…, env:) → binPath = lines.last.
  • skipstone/Sources/SkipBuild/Commands/AndroidTestCommand.swift: captureLine(...) is documented as "the last non-empty stdout line" but also calls launchTool with the default includeStdErr: true; it is used for --show-bin-path (harness and --build-tests).

The --show-bin-path lookup was introduced in skiptools/skipstone#245 (swiftbuild support). The stdout/stderr output shape of --show-bin-path with --build-system native is visible in swiftlang/swift-build#1363.

Versions

  • Skip 1.9.8 (Homebrew, invoked by Gradle) and 1.9.12 (Package.resolved), macOS, Skip Fuse app.
  • The code is unchanged on main at 1.9.21 (3dfa66f).

Suggested fix

  • Pass includeStdErr: false for the --show-bin-path invocations (and in captureLine), and/or
  • pick the last line that is an absolute path to an existing directory instead of lines.last.

Workaround we use

Retry the Gradle assemble once when the log contains both Code=260 and adopt the default build system.

Lingua principale
Swift
Stelle
3.3k
Fork
115
Merge medio
1g 15h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di skiptools/skip

Tutte le issue di skiptools/skip

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.