Skip to content

Fix nil bug when there's no dependency key in package.json#791

Merged
MikeMcQuaid merged 1 commit into
licensee:mainfrom
koddsson:patch-1
Feb 6, 2025
Merged

Fix nil bug when there's no dependency key in package.json#791
MikeMcQuaid merged 1 commit into
licensee:mainfrom
koddsson:patch-1

Conversation

@koddsson

Copy link
Copy Markdown
Contributor

I just have devDependencies in my project and I'm getting this error:

Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/sources/npm.rb:68:in 'Licensed::Sources::NPM#recursive_dependencies': undefined method 'each' for nil (NoMethodError)

        dependencies.each do |name, dependency|
                    ^^^^^
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/sources/npm.rb:52:in 'Licensed::Sources::NPM#packages'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/sources/npm.rb:31:in 'Licensed::Sources::NPM#enumerate_dependencies'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/sources/source.rb:102:in 'Licensed::Sources::Source#cached_dependencies'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/sources/source.rb:78:in 'Licensed::Sources::Source#dependencies'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/command.rb:136:in 'Licensed::Commands::Command#run_source'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/cache.rb:55:in 'Licensed::Commands::Cache#run_source'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/command.rb:101:in 'block (2 levels) in Licensed::Commands::Command#run_app'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/command.rb:98:in 'Array#map'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/command.rb:98:in 'block in Licensed::Commands::Command#run_app'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/command.rb:95:in 'Dir.chdir'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/command.rb:95:in 'Licensed::Commands::Command#run_app'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/cache.rb:41:in 'block in Licensed::Commands::Cache#run_app'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/cache.rb:167:in 'Licensed::Commands::Cache#with_licensee_configuration'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/cache.rb:40:in 'Licensed::Commands::Cache#run_app'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/command.rb:67:in 'block in Licensed::Commands::Command#run_command'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/command.rb:64:in 'Array#map'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/command.rb:64:in 'Licensed::Commands::Command#run_command'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/cache.rb:24:in 'Licensed::Commands::Cache#run_command'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/commands/command.rb:23:in 'Licensed::Commands::Command#run'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/cli.rb:115:in 'Licensed::CLI#run'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/lib/licensed/cli.rb:18:in 'Licensed::CLI#cache'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/thor-1.3.2/lib/thor/command.rb:28:in 'Thor::Command#run'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/thor-1.3.2/lib/thor/invocation.rb:127:in 'Thor::Invocation#invoke_command'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/thor-1.3.2/lib/thor.rb:538:in 'Thor.dispatch'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/thor-1.3.2/lib/thor/base.rb:584:in 'Thor::Base::ClassMethods#start'
	from /Users/koddsson/src/koddsson/console/vendor/bundle/ruby/3.4.0/gems/licensed-5.0.1/exe/licensed:5:in '<top (required)>'
	from bin/licensed:27:in 'Kernel#load'
	from bin/licensed:27:in '<main>'

This patch should fix it by defaulting to a empty hash if dependencies is nil.

@koddsson

Copy link
Copy Markdown
Contributor Author

I just noticed that this gem is in low maintenance mode 🤔

Licensed is currently in low maintenance mode. At this point, we're only looking to maintain this repository for security fixes.

@dangoor

dangoor commented Jan 28, 2025

Copy link
Copy Markdown
Contributor

@koddsson We should hopefully soon have this in a better maintenance position! Sorry for the delay.

@koddsson

Copy link
Copy Markdown
Contributor Author

@koddsson We should hopefully soon have this in a better maintenance position! Sorry for the delay.

All good, thanks for the update!

@MikeMcQuaid

Copy link
Copy Markdown
Contributor

Thanks @koddsson! Merging because these failures are happening consistently across PRs and are not specific to this one.

@MikeMcQuaid MikeMcQuaid merged commit f60ff87 into licensee:main Feb 6, 2025
@koddsson koddsson deleted the patch-1 branch February 6, 2025 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants