Skip to content

Fix bug in cargo parent path detection #4491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Next release
https://github.com/aboutcode-org/scancode-toolkit/pull/4474
https://github.com/aboutcode-org/scancode-toolkit/issues/4101

- Fix: Prevent crash when parent resource is missing in Cargo package assembler. Thanks [@Iron-56](https://github.com/Iron-56)!
https://github.com/nexB/scancode-toolkit/issues/1436


v32.4.1 - 2025-07-23
--------------------
Expand Down
5 changes: 3 additions & 2 deletions src/packagedcode/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def assemble(cls, package_data, resource, codebase, package_adder):
package_data.extra_data[attribute] = 'workspace'
workspace_package_data[attribute] = getattr(package_data, attribute)

workspace_root_path = resource.parent(codebase).path
parent = resource.parent(codebase)
workspace_root_path = parent.path if parent else None
if workspace_package_data and workspace_members:

# TODO: support glob patterns found in cargo workspaces
Expand Down Expand Up @@ -97,7 +98,7 @@ def assemble(cls, package_data, resource, codebase, package_adder):
else:
yield from cls.assemble_from_many_datafiles(
datafile_name_patterns=('Cargo.toml', 'cargo.toml', 'Cargo.lock', 'cargo.lock'),
directory=resource.parent(codebase),
directory=resource.parent(codebase) or resource,
codebase=codebase,
package_adder=package_adder,
)
Expand Down
Loading