Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

`third-party-licenses` fails on Windows when the parent process is PowerShell

Ouverte Adaptée aux débutants
#4,745 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
76/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
powershell, rust

Piste de recherche

Commencez dans tools/third-party-licenses/src/cargo.rs, en particulier dans run(), et suivez la manière dont cargo about est invoqué et dont sa sortie est analysée. Exécutez la commande de reproduction depuis PowerShell ; le travail est terminé lorsque le JSON des licences est lu avec succès et que l’outil fonctionne lorsque PowerShell est un processus ancêtre.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Summary

tools/third-party-licenses runs cargo about generate --format json --locked and parses stdout. On Windows, if PowerShell appears anywhere in the parent process chain, cargo-about refuses to write JSON to stdout and exits with an error telling you to use -o / --output-file.

That breaks cargo run desktop (and any CI/agent that launches the build from PowerShell), even though cargo-about itself is installed and works when given an output file.

Environment

  • OS: Windows 10/11
  • Shell: PowerShell 5.1 / PowerShell 7 (also fails when an ancestor is PowerShell, e.g. Cursor/VS Code terminal, cargo-run spawned from pwsh)
  • cargo-about 0.9.x (behavior from EmbarkStudios/cargo-about#198 / PR that added is_powershell_parent())

Steps to reproduce

  1. On Windows, open PowerShell in a Graphite checkout.
  2. Ensure cargo-about is on PATH.
  3. Run:
cargo run -p third-party-licenses --features desktop

(or the same step via cargo run desktop)

Expected

License JSON is generated and the tool succeeds.

Actual

cargo about generate fails roughly with:

cargo-about should not redirect its output in powershell

(or similar wording pointing at -o, --output-file). Redirecting/piping from the Graphite side does not help: the check walks ancestor processes, so Command::output() capturing stdout is enough to trigger it whenever PowerShell is an ancestor.

Root cause

Current code in tools/third-party-licenses/src/cargo.rs (run()):

Command::new("cargo")
    .args(["about", "generate", "--format", "json", "--locked"])
    // … reads output.stdout

cargo-about intentionally blocks stdout under PowerShell (UTF-16 / encoding footgun). The supported API is writing to a file with -o.

Suggested fix

Write to a temp file with -o, then read and parse that file (delete afterward). Minimal patch:

fn run() -> Result<Output, Error> {
	let out_path = std::env::temp_dir().join(format!("graphite-about-{}.json", std::process::id()));
	let output = Command::new("cargo")
		.args([
			"about",
			"generate",
			"--format",
			"json",
			"--locked",
			"-o",
			out_path.to_str().ok_or_else(|| Error::Command("about output path is not UTF-8".into()))?,
		])
		.current_dir(env!("CARGO_WORKSPACE_DIR"))
		.output()
		.map_err(|e| Error::Io(e, "Failed to run cargo about generate".into()))?;

	if !output.status.success() {
		let _ = std::fs::remove_file(&out_path);
		return Err(Error::Command(format!(
			"cargo about generate failed:\n{}",
			String::from_utf8_lossy(&output.stderr)
		)));
	}

	let json = std::fs::read_to_string(&out_path).map_err(|e| Error::Io(e, format!("reading {}", out_path.display())))?;
	let _ = std::fs::remove_file(&out_path);

	serde_json::from_str(&json).map_err(|e| Error::Json(e, "Failed to parse cargo about generate JSON".into()))
}

This is also slightly more robust on non-Windows hosts (no reliance on capturing a large JSON blob from a pipe).

Workaround (today)

# Skip the failing step and continue the desktop bundle, or invoke about with -o manually:
cargo about generate --format json --locked -o $env:TEMP\about.json

References

  • EmbarkStudios/cargo-about#198 (PowerShell / stdout encoding; led to rejecting stdout under PowerShell)
  • Graphite call site: tools/third-party-licenses/src/cargo.rs → run()
  • Invoked from desktop flow: cargo run desktop → third-party-licenses with --features desktop
Langage dominant
Rust
Étoiles
27.6k
Forks
1.3k
Merge moyen
22 h 50 min
PR mergées (30 j)
143

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

  • Aucun Dockerfile ni fichier Docker Compose
  • Propose un modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de GraphiteEditor/Graphite

Toutes les issues de GraphiteEditor/Graphite

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.