Skip to content
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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

koddsson
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants