davetron5000 / optparse-plus

Start your command line scripts off right in Ruby
http://davetron5000.github.com/optparse-plus
Apache License 2.0
521 stars 54 forks source link

"You have one or more invalid gemspecs that need to be fixed." #103

Closed mbigras closed 7 years ago

mbigras commented 7 years ago

Hey Dave!

Thanks for such an awesome book, the rich formatting is such a joy to read :)

I'm trying to use methadone but am having some issues. Please see the output below:

repos ❯ methadone --readme --license=apache fullstop
repos ❯ cd fullstop
fullstop git:master ❯ bundle install                                                                                                                       
You have one or more invalid gemspecs that need to be fixed.
The gemspec at /Users/max/repos/fullstop/fullstop.gemspec is not valid. Please fix this gemspec.
The validation error was '"FIXME" or "TODO" is not a description'
fullstop git:master ❯ bundle -v                                                                                                                           
Bundler version 1.12.5
fullstop git:master ❯ rbenv -v                                                                                                                             
rbenv 1.0.0
fullstop git:master ❯ ruby -v                                                                                                                              
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
fullstop git:master ❯ cat Gemfile                                                                                                                           
source 'https://rubygems.org'

# Specify your gem's dependencies in fullstop.gemspec
gemspec

I know in the your book you reccommend rvm and ruby 1.9.3 is it this why I'm having problems?

Thanks :)

davetron5000 commented 7 years ago

Thanks!

The output of bundle install is telling you the problem amidst its other messages:

The validation error was '"FIXME" or "TODO" is not a description'

It seems some newer versions of bundler don't like a gemspec where you haven't filled in a proper description. I guess methadone could not do this, but maybe try changing it before the bundle install?

ON a side note, the latest ruby (2.3.x) should work fine, and I think 1.9.x is no longer supported (that book is now kinda old! :)

mbigras commented 7 years ago

Thanks for getting back to me :) So it sounds like the problem has to do with the formatting of my Gemfile or fullstop.gemspec? How should I modify either of those files to make bundler happy?

fullstop git:master ❯ cat fullstop.gemspec                                                                                                                
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'fullstop/version'

Gem::Specification.new do |spec|
  spec.name          = "fullstop"
  spec.license="apache"
  spec.version       = Fullstop::VERSION
  spec.authors       = ["mbigras"]
  spec.email         = ["mbigras22@gmail.com"]

  spec.summary       = %q{TODO: Write a short summary, because Rubygems requires one.}
  spec.description   = %q{TODO: Write a longer description or delete this line.}
  spec.homepage      = "TODO: Put your gem's website or public repo URL here."

  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
  # to allow pushing to a single host or delete this section to allow pushing to any host.
  if spec.respond_to?(:metadata)
    spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
  else
    raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
  end

  spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
  spec.bindir        = "exe"
  spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
  spec.require_paths = ["lib"]

  spec.add_development_dependency "bundler", "~> 1.12"
  spec.add_development_dependency "rake", "~> 10.0"
  spec.add_development_dependency('rdoc')
  spec.add_development_dependency('aruba')
  spec.add_development_dependency('rake')
  spec.add_dependency('methadone', '~> 1.9.2')
  spec.add_development_dependency('test-unit')
end

after editing description:

# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'fullstop/version'

Gem::Specification.new do |spec|
  spec.name          = "fullstop"
  spec.license="apache"
  spec.version       = Fullstop::VERSION
  spec.authors       = ["mbigras"]
  spec.email         = ["mbigras22@gmail.com"]

  spec.summary       = "cats and dogs"
  spec.description   = "cats and dogs"
  spec.homepage      = "TODO: Put your gem's website or public repo URL here."

  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
  # to allow pushing to a single host or delete this section to allow pushing to any host.
  if spec.respond_to?(:metadata)
    spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
  else
    raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
  end

  spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
  spec.bindir        = "exe"
  spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
  spec.require_paths = ["lib"]

  spec.add_development_dependency "bundler", "~> 1.12"
  spec.add_development_dependency "rake", "~> 10.0"
  spec.add_development_dependency('rdoc')
  spec.add_development_dependency('aruba')
  spec.add_development_dependency('rake')
  spec.add_dependency('methadone', '~> 1.9.2')
  spec.add_development_dependency('test-unit')
end

I get the following error:

You have one or more invalid gemspecs that need to be fixed.
The gemspec at /Users/max/repos/fullstop/fullstop.gemspec is not valid. Please fix this gemspec.
The validation error was 'duplicate dependency on rake (>= 0, development), (~> 10.0) use:
    add_development_dependency 'rake', '>= 0', '~> 10.0'
'

Note: I'll keep updating this post as I work through the errors

davetron5000 commented 7 years ago

Yeah, this is the key part:

duplicate dependency on rake (>= 0, development), (~> 10.0)

which is not super clear, but means you have a development dependency on rake as well as a runtime dependency and it wants only one of those two. What's weird is that you don't have that in your gemspec. My guess is maybe methadone is pulling it in for runtime?

I'd make sure it's not in your Gemfile and then remove the development dependency from the gemspec…

mbigras commented 7 years ago

See the diff for how to get up and running:

# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'fullstop/version'

Gem::Specification.new do |spec|
  spec.name          = "fullstop"
  spec.license="apache"
  spec.version       = Fullstop::VERSION
  spec.authors       = ["mbigras"]
  spec.email         = ["mbigras22@gmail.com"]

  spec.summary       = "cats and dogs"
  spec.description   = "cats and dogs"
  spec.homepage      = "TODO: Put your gem's website or public repo URL here."

  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
  # to allow pushing to a single host or delete this section to allow pushing to any host.
  if spec.respond_to?(:metadata)
    spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
  else
    raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
  end

  spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
  spec.bindir        = "exe"
  spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
  spec.require_paths = ["lib"]

  spec.add_development_dependency "bundler", "~> 1.12"
  spec.add_development_dependency "rake", "~> 10.0"
  spec.add_development_dependency('rdoc')
  spec.add_development_dependency('aruba')
  spec.add_development_dependency('cucumber')
  # spec.add_development_dependency('rake')
  spec.add_dependency('methadone', '~> 1.9.2')
  spec.add_development_dependency('test-unit')
end

thanks for the help, looking forward to working through your book 😄

ps: there was no duplicate in the Gemfile it was all in fullstop.gemspec

source 'https://rubygems.org'

# Specify your gem's dependencies in fullstop.gemspec
gemspec
mbigras commented 7 years ago

one more question, which tool did you use to make this book? It's really awesome being able to have animated notations of the code

davetron5000 commented 7 years ago

I used iBooks Author. Which, ironcially, makes it hard for me to update it with the stuff you've discovered because I'd likely have to re-record some of the screencasts :(

mbigras commented 7 years ago

Hi Dave,

Just wanted to follow up on this. There are three substitutions I need to make before methadone "just works".

I've attached them below with the associated errors. They are:

  1. For some reason bundle isn't happy about TODO, it needs to be todo
  2. The spec.homepage need to either be empty or some site-like pattern like https://rubygems.org
  3. rake can't exist as a dependency twice

I've been digging around but I only found comments about the TODO situation, I can't find any occurrences of the string homepage anywhere, and I don't know how the spec.add_development_dependency "rake", "~> 10.0" gets generated.

Not sure if this is an easy fix for you, but I think it would be great to be able to get off and running with just one command and not have to make substitutions.

If you give me some hints as to where in the templates or in methadone the above three are being generated I'd be happy to help. Otherwise, I'll just write a script to make the substitutions that I showed.

➜  hello-methadone master ✗ bundle
You have one or more invalid gemspecs that need to be fixed.
The gemspec at /Users/max/Dropbox/work/tmp/hello-methadone/hello-methadone.gemspec is not valid. Please fix this gemspec.
The validation error was '"FIXME" or "TODO" is not a description'
➜  hello-methadone master ✗ sed 's/TODO: //g' hello-methadone.gemspec > tmp
➜  hello-methadone master ✗ mv tmp hello-methadone.gemspec
➜  hello-methadone master ✗ bundle
You have one or more invalid gemspecs that need to be fixed.
The gemspec at /Users/max/Dropbox/work/tmp/hello-methadone/hello-methadone.gemspec is not
valid. Please fix this gemspec.
The validation error was '"Put your gem's website or public repo URL here." is not a URI'
➜  hello-methadone master ✗ sed "s/Put your gem's website or public repo URL here./https:\/\/github.com\/mbigras/" hello-methadone.gemspec > tmp
➜  hello-methadone master ✗ mv tmp hello-methadone.gemspec
➜  hello-methadone master ✗ bundle
You have one or more invalid gemspecs that need to be fixed.
The gemspec at /Users/max/Dropbox/work/tmp/hello-methadone/hello-methadone.gemspec is not valid. Please fix this gemspec.
The validation error was 'duplicate dependency on rake (>= 0, development), (~> 10.0) use:
    add_development_dependency 'rake', '>= 0', '~> 10.0'
'
➜  hello-methadone master ✗ sed 's/spec.add_development_dependency "rake", "~> 10.0"//' hello-methadone.gemspec > tmp
➜  hello-methadone master ✗ mv tmp hello-methadone.gemspec
➜  hello-methadone master ✗ bundle
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 11.3.0
Using ffi 1.9.14
Using contracts 0.14.0
Using builder 3.2.2
Using gherkin 4.0.0
Using cucumber-wire 0.0.1
Using diff-lcs 1.2.5
Using multi_json 1.12.1
Using multi_test 0.1.2
Using rspec-support 3.5.0
Using thor 0.19.1
Using bundler 1.13.6
Using power_assert 0.3.1
Using rdoc 4.3.0
Using childprocess 0.5.9
Using cucumber-core 1.5.0
Using rspec-expectations 3.5.0
Using methadone 1.9.3
Using test-unit 3.2.2
Using cucumber 2.4.0
Using hello-methadone 0.1.0 from source at `.`
Using aruba 0.14.2
Bundle complete! 6 Gemfile dependencies, 22 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
➜  hello-methadone master ✗ bundle exec bin/hello-methadone -h
Usage: hello-methadone [options]

v0.1.0

Options:
    -h, --help                       Show command line help
        --version                    Show help/version info
        --log-level LEVEL            Set the logging level
                                     (debug|info|warn|error|fatal)
                                     (Default: info)
davetron5000 commented 7 years ago

All the templates are in https://github.com/davetron5000/methadone/tree/master/templates but the gemspec is created by bundler here: https://github.com/davetron5000/methadone/blob/master/bin/methadone#L26

So, to do what you are wanting you'd have to edit the generated gemspec. Bundler is generating it this way because it wants you to change those things before proceeding, so the behavior is somewhat intentional.

The duplicate rake dependency might be due to bundle gem now adding it when it didn't, or it could be the result of changes in Ruby over the years. Either way, if you just omit it entirely, you will break anyone on older bundlers/rubies.

I wonder if removing bundler from the gemspec creation is a better solution, since it means this app can totally control the gemspec…