about summary refs log tree commit diff
path: root/pkgs/build-support/rust
diff options
context:
space:
mode:
authorD Anzorge <d.anzorge@gmail.com>2023-03-22 16:11:36 +0100
committerzowoq <59103226+zowoq@users.noreply.github.com>2023-03-24 15:45:16 +1000
commitc86b1a0bca28e5459530bef49afe127fd874a077 (patch)
tree47ef06022b49b297a34cad2db78441b7ebd73e5e /pkgs/build-support/rust
parent6085b3b7f76c8be200a22c449f39b89ed513de24 (diff)
rustPlatform.importCargoLock: handle workspace Cargo.toml false positives
Since we grep for 'workspace', it's possible the script ends up running
on a Cargo.toml that has the word 'workspace' in a comment, but does not
actually use workspaces
Diffstat (limited to 'pkgs/build-support/rust')
-rw-r--r--pkgs/build-support/rust/replace-workspace-values.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/pkgs/build-support/rust/replace-workspace-values.py b/pkgs/build-support/rust/replace-workspace-values.py
index fe54628833027..f5108f840b336 100644
--- a/pkgs/build-support/rust/replace-workspace-values.py
+++ b/pkgs/build-support/rust/replace-workspace-values.py
@@ -63,8 +63,16 @@ def replace_dependencies(
 
 
 def main() -> None:
+    top_cargo_toml = load_file(sys.argv[2])
+
+    if "workspace" not in top_cargo_toml:
+        # If top_cargo_toml is not a workspace manifest, then this script was probably
+        # ran on something that does not actually use workspace dependencies
+        print(f"{sys.argv[2]} is not a workspace manifest, doing nothing.")
+        return
+
     crate_manifest = load_file(sys.argv[1])
-    workspace_manifest = load_file(sys.argv[2])["workspace"]
+    workspace_manifest = top_cargo_toml["workspace"]
 
     if "workspace" in crate_manifest:
         return