SPM local packages
I got this error when trying to find licenses for SPM. It happens because a local package hasn't checkoutState in .build/workspace-state.json like below. When I modify the .build/workspace-state.json by adding checkoutState object to all local packages, it works and lists local packages as local_package_name, added_version, unknown.
| Remote | Local |
|---|---|
|
|
Package.swift
let package = Package(
name: "PackageName",
dependencies: [
.package(url: "remote_package_url", from: "remote_package_version"),
.package(path: "local_package_path"),
]
)
.build/workspace-state.json
{
"object" : {
"artifacts" : [
],
"dependencies" : [
{
"basedOn" : null,
"packageRef" : {
"identity" : "local_package",
"kind" : "fileSystem",
"location" : "local_package_path",
"name" : "local_package"
},
"state" : {
"name" : "fileSystem",
"path" : "local_package_path"
},
"subpath" : "local_package"
},
]
},
"version" : 1
}
Terminal
LicenseFinder::Spm: is active
bundler: failed to load command: license_finder (/Users/yunustur/.gem/bin/license_finder)
/Users/yunustur/.gem/gems/license_finder-7.1.0/lib/license_finder/package_managers/spm.rb:22:in `block in current_packages': undefined method `[]' for nil:NilClass (NoMethodError)
package_version = checkout_state['version'] || checkout_state['revision']
^^^^^^^^^^^
from /Users/yunustur/.gem/gems/license_finder-7.1.0/lib/license_finder/package_managers/spm.rb:16:in `map'
from /Users/yunustur/.gem/gems/license_finder-7.1.0/lib/license_finder/package_managers/spm.rb:16:in `current_packages'
from /Users/yunustur/.gem/gems/license_finder-7.1.0/lib/license_finder/package_manager.rb:105:in `current_packages_with_relations'
from /Users/yunustur/.gem/gems/license_finder-7.1.0/lib/license_finder/scanner.rb:42:in `each'
from /Users/yunustur/.gem/gems/license_finder-7.1.0/lib/license_finder/scanner.rb:42:in `flat_map'
from /Users/yunustur/.gem/gems/license_finder-7.1.0/lib/license_finder/scanner.rb:42:in `active_packages'
from /Users/yunustur/.gem/gems/license_finder-7.1.0/lib/license_finder/core.rb:84:in `current_packages'
from /Users/yunustur/.gem/gems/license_finder-7.1.0/lib/license_finder/core.rb:79:in `decision_applier'
from /opt/homebrew/Cellar/ruby/3.2.2_1/lib/ruby/3.2.0/forwardable.rb:234:in `any_packages?'
from /Users/yunustur/.gem/gems/license_finder-7.1.0/lib/license_finder/license_aggregator.rb:17:in `block in any_packages?'
from /Users/yunustur/.gem/gems/license_finder-7.1.0/lib/license_finder/license_aggregator.rb:15:in `map'
from /Users/yunustur/.gem/gems/license_finder-7.1.0/lib/license_finder/license_aggregator.rb:15:in `any_packages?'
from /Users/yunustur/.gem/gems/license_finder-7.1.0/lib/license_finder/cli/main.rb:121:in `action_items'
from /Users/yunustur/.gem/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
from /Users/yunustur/.gem/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/yunustur/.gem/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
from /Users/yunustur/.gem/gems/thor-1.2.2/lib/thor/base.rb:485:in `start'
from /Users/yunustur/.gem/gems/license_finder-7.1.0/bin/license_finder:6:in `<top (required)>'
from /Users/yunustur/.gem/bin/license_finder:25:in `load'
from /Users/yunustur/.gem/bin/license_finder:25:in `<top (required)>'
from /Users/yunustur/.gem/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `load'
from /Users/yunustur/.gem/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `kernel_load'
from /Users/yunustur/.gem/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:23:in `run'
from /Users/yunustur/.gem/gems/bundler-2.4.19/lib/bundler/cli.rb:492:in `exec'
from /Users/yunustur/.gem/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /Users/yunustur/.gem/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/yunustur/.gem/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from /Users/yunustur/.gem/gems/bundler-2.4.19/lib/bundler/cli.rb:34:in `dispatch'
from /Users/yunustur/.gem/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from /Users/yunustur/.gem/gems/bundler-2.4.19/lib/bundler/cli.rb:28:in `start'
from /Users/yunustur/.gem/gems/bundler-2.4.19/exe/bundle:37:in `block in <top (required)>'
from /Users/yunustur/.gem/gems/bundler-2.4.19/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
from /Users/yunustur/.gem/gems/bundler-2.4.19/exe/bundle:29:in `<top (required)>'
from /opt/homebrew/opt/ruby/bin/bundle:25:in `load'
from /opt/homebrew/opt/ruby/bin/bundle:25:in `<main>'
We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story.
The labels on this github issue will be updated when the story is started.
Hey @yut-ioki ! Thanks for raising this. We are very short on resources so if you could make a PR for this we can get it in :)