简体   繁体   中英

Having trouble publishing my Ruby gem due to NoMethod errors and problems relating to my .gemspec file

I'm receiving this error when executing gem push pick_a_key-0.1.0.gem

ERROR:  While executing gem ... (NoMethodError)
    undefined method `downcase' for nil:NilClass

I'm not entirely sure why I'm receiving it considering the app works fine when I run it.

I've also tried running bundle exec rake build When this is run, I receive:

32: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
    31: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
    30: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/setup.rb:10:in `<top (required)>'
    29: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/ui/shell.rb:88:in `silence'
    28: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/ui/shell.rb:136:in `with_level'
    27: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/setup.rb:10:in `block in <top (required)>'
    26: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler.rb:142:in `setup'
    25: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler.rb:194:in `definition'
    24: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:34:in `build'
    23: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/dsl.rb:13:in `evaluate'
    22: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/dsl.rb:232:in `to_definition'
    21: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/dsl.rb:232:in `new'
    20: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:124:in `initialize'
    19: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:643:in `converge_paths'
    18: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:643:in `any?'
    17: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:644:in `block in converge_paths'
    16: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:600:in `specs_changed?'
    15: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:615:in `specs_for_source_changed?'
    14: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:113:in `specs'
    13: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:105:in `local_specs'
    12: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:174:in `load_spec_files'
    11: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:174:in `each'
    10: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:180:in `block in load_spec_files'
     9: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:166:in `validate_spec'
     8: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/rubygems_integration.rb:70:in `validate'
     7: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/ui/shell.rb:88:in `silence'
     6: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/ui/shell.rb:136:in `with_level'
     5: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/rubygems_integration.rb:70:in `block in validate'
     4: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:2588:in `validate'
     3: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/rubygems/specification_policy.rb:44:in `validate'
     2: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/rubygems/specification_policy.rb:75:in `validate_required!'
     1: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/rubygems/specification_policy.rb:306:in `validate_self_inclusion_in_files_list'
/home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/rubygems/specification_policy.rb:477:in `error': pick_a_key-0.1.0 contains itself (pick_a_key-0.1.0.gem), check your files list (Gem::InvalidSpecificationException)
    25: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
    24: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
    23: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/setup.rb:10:in `<top (required)>'
    22: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/ui/shell.rb:88:in `silence'
    21: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/ui/shell.rb:136:in `with_level'
    20: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/setup.rb:10:in `block in <top (required)>'
    19: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler.rb:142:in `setup'
    18: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler.rb:194:in `definition'
    17: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:34:in `build'
    16: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/dsl.rb:13:in `evaluate'
    15: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/dsl.rb:232:in `to_definition'
    14: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/dsl.rb:232:in `new'
    13: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:124:in `initialize'
    12: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:643:in `converge_paths'
    11: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:643:in `any?'
    10: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:644:in `block in converge_paths'
     9: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:600:in `specs_changed?'
     8: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:615:in `specs_for_source_changed?'
     7: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:113:in `specs'
     6: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:105:in `local_specs'
     5: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:174:in `load_spec_files'
     4: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:174:in `each'
     3: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:180:in `block in load_spec_files'
     2: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:166:in `validate_spec'
     1: from /home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/rubygems_integration.rb:69:in `validate'
/home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0/bundler/rubygems_integration.rb:74:in `rescue in validate': The gemspec at /home/taylor/code/pick_a_key/pick_a_key.gemspec is not valid. Please fix this gemspec. (Gem::InvalidSpecificationException)
The validation error was 'pick_a_key-0.1.0 contains itself (pick_a_key-0.1.0.gem), check your files list'

Below is my pick_a_key.gemspec file:

# frozen_string_literal: true

require_relative "lib/pick_a_key/version"

Gem::Specification.new do |spec|
  spec.name          = "pick_a_key"
  spec.version       = PickAKey::VERSION
  spec.authors       = ["Taylor Treece"]
  spec.email         = ["xxxxxxxx.com"]

  spec.summary       = "The Pick-a-Key gem allows you to quickly find relevant information on music theory, specifically relating to Major and Minor keys."
  spec.description   = "When started, the gem lists all available Major and minor keys, and then prompts you to make a selection. Once selected, a key object is made a available to the user. The attributes related to the key object are :Type (Major or minor), :Name (e.g. C Major ), :Notes (all notes in the listed key), :Chords (all chords in listed key), :Relative_fifth, :Relative_Major/:Relative_minor. The user also has the option of having a single random chord progression returned to them in a key of their choice, or an entire song written in the key of their choice."
  spec.homepage      = "https://github.com/taylortreece/pick-a-key.git."
  spec.license       = "MIT"
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")

  spec.metadata["allowed_push_host"] = 'rubygems.org'

  spec.metadata["homepage_uri"] = spec.homepage

  # Specify which files should be added to the gem when it is released.
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
    `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
  end
  #spec.bindir        = "exe"
  spec.executables   = ["pick-a-key"]
  #spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
  spec.require_paths = ["lib"]
  spec.add_development_dependency "pry"
  spec.add_dependency "nokogiri"
  spec.add_dependency "prettyprint"

  # Uncomment to register a new dependency of your gem
  # spec.add_dependency "example-gem", "~> 1.0"

Any idea on what I should do? I'm positive something is wrong with my gemspec considering the error messages, but I'm just not sure how to go about solving it.

The last lines of the error are the important ones. pick_a_key-0.1.0.gem is part of the files that you included in your git repo (got them later in your gemspec file by git ls-files -z ).
So, remove the file from your repository and that should make the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM