6

I am trying to create a new Ruby on Rails application. Every time I type in rails new after, I get this error

/usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/parser/option.rb:130:in `validate_default_type!': An option's default must match its type. (ArgumentError)
    from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/parser/option.rb:113:in `validate!'
    from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/parser/argument.rb:24:in `initialize'
    from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/parser/option.rb:9:in `initialize'
    from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/base.rb:544:in `new'
    from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/base.rb:544:in `build_option'
    from /usr/local/lib/ruby/gems/2.2.0/gems/thor-0.19.2/lib/thor/base.rb:278:in `class_option'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/base.rb:202:in `class_option'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/app_base.rb:71:in `add_shared_options_for'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/rails/app/app_generator.rb:160:in `<class:AppGenerator>'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/rails/app/app_generator.rb:159:in `<module:Generators>'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/rails/app/app_generator.rb:153:in `<module:Rails>'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/rails/app/app_generator.rb:3:in `<top (required)>'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/application.rb:2:in `<top (required)>'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/cli.rb:14:in `<top (required)>'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5/bin/rails:9:in `<top (required)>'
    from /usr/local/bin/rails:23:in `load'
    from /usr/local/bin/rails:23:in `<main>' 

I have Ruby on Rails installed on my computer and have written other Ruby on Rails applications. Any ideas of why I am getting this error and how can I fix it?

2

4 Answers 4

4

It seems the latest gem release broke it. Once that gets fixed, then this error should go away.

A temporary fix if you already have a Ruby on Rails app is to set the version of Thor in your Gemfile to the last release:

gem 'thor', '0.19.1'

Alternatively if you are having trouble creating a new Ruby on Rails application, you can uninstall Thor and install an older version:

gem uninstall thor
gem install thor -v 0.19.1
8
  • I tried gem install thor '0.19.1', but get an error that the gem cannot be found
    – Aaron
    Nov 26, 2016 at 22:13
  • This goes in your Gemfile. It's not a command for the terminal.
    – excid3
    Nov 26, 2016 at 22:16
  • How would I find the gem file if I cannot create the app?
    – Aaron
    Nov 26, 2016 at 22:17
  • The app should have generated fine (mine do) but when I run a generator, then it fails. Share your whole logs before the error?
    – excid3
    Nov 26, 2016 at 22:20
  • I thought I did above. If not where do I get to get the entire log?
    – Aaron
    Nov 26, 2016 at 22:29
0

I had the same problem, turns out I had to uninstall thor both in my system, and in my rails app.

I also could not generate a new app so in command line, so I had to:

gem uninstall thor
gem install thor -v 0.19.1

Then rails commands works in command line again

I then generated a new rails app, but this failed to, since it get the broken version. So in my gem file I required the right version:

gem 'thor', '0.19.1'

and then run

bundle install

oh, no!

"You have requested:
  thor = 0.19.1

The bundle currently has thor locked at 0.19.2.
Try running `bundle update thor`"

so then

bundle update 

and voila!! :)

Using thor 0.19.1 (was 0.19.2)

And the failing command now runs:

rails generate rspec:install
Running via Spring preloader in process 26996
      create  .rspec
      create  spec
      create  spec/spec_helper.rb
      create  spec/rails_helper.rb
0

i just found thor 0.19.3 is out and works now. I'm only a week into playing around with rails so for those other newbies I didn't find any reference to thor in the gemsfile in my app but I simply added it as Benjamin showed except using 0.19.3 and did the bundle update thor and it's working now. Everything else I did before with 0.19.1 got me rails new but then failed on generating a scaffolding.

-1

I tried:

gem install thor '0.19.1'. 

And I got:

Could not find a valid gem '0.19.1' (>= 0) in any repository.

Erik Michaels-Ober changed the Thor gem. And rails new works only with Ruby on Rails v. 5.0. And there are no old versions of this gem. Ruby on Rails now work only with version 5.0. Ruby on Rails 4.2.6 is over. Erik Michaels-Ober and gem kills old versions of Ruby on Rails.

2
  • Your command is incorrect. You need "gem install thor -v 0.19.1"
    – excid3
    Nov 26, 2016 at 22:43
  • 1
    Thanks! gem install thor -v 0.19.1 is a solution of problem/ I had the same probltm as Aaron and you show the solution Nov 26, 2016 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.