2

UPDATE:

So it turns out the issue is has to do with me corrupting confg/boot.rb. Details are in the answer below.


So basically rake stopped working. I'm trying to add a new model, and if I then run

rake db:migrate

I get:

Error: Command 'db:migrate' not recognized

I'm pretty sure rake is correctly installed and sourced though. If I run:

rake

I get the normal 'man' page starting with

Usage: rails COMMAND [ARGS]...The most common rails commands are...

Interestingly enough it also spits this out at the bottom:

.../db/schema.rb doesn't exist yet. Run 'rake db:migrate' to create it, then try again. If you do not intend to use a database, you should instead alter .../config/application.rb to limit the frameworks that will be loaded.

I do intend to use a database, so I'd love to get rake working...

Am I missing something obvious?

Thanks ahead of time!

cjhin
  • 235
  • 4
  • 16

2 Answers2

2

Did you try it via bundle?

bundle exec rake db:migrate
BvuRVKyUVlViVIc7
  • 11,641
  • 9
  • 59
  • 111
0

So it turns out the issue is due to me incorrectly following instructions on a SO post regarding changing the port that rails server binds to.

Basically I incorrectly modified config/boot.rb which somehow corrupted the behavior of rake.

Specifically I completely misread and mashed together the top two answers, appending the following code to config/boot.rb instead of placing it in a standalone script.

# THIS IS NEW:
require "rails/commands/server"
module Rails
  class Server
    def default_options
      super.merge({
        :Port        => 10524,
        :environment => (ENV['RAILS_ENV'] || "development").dup,
        :daemonize   => false,
        :debugger    => false,
        :pid         => File.expand_path("tmp/pids/server.pid"),
        :config      => File.expand_path("config.ru")
      })
    end
  end
end
# END OF CHANGE
require 'rails/commands'

Sorry guys. Thanks for the help though!

Community
  • 1
  • 1
cjhin
  • 235
  • 4
  • 16
  • Hey @cjhin I just did the same thing. How'd you fix it? – j0e Jan 09 '14 at 04:55
  • @j0e When you say "the same thing", do you mean the same issue with incorrectly modifying config/boot.rb? – cjhin Jan 09 '14 at 04:57
  • Yes. I needed to set my server into using port 9999 by default for some testing and it borked my rake command. I editing the boot.rb back to what it was before but it's still messed up. How'd you fix yours? – j0e Jan 09 '14 at 07:43
  • honestly I think I just created a new rails app and ported over the data I needed... sorry that's probably not the answer you were hoping for – cjhin Jan 10 '14 at 07:45
  • Thanks cjhin that's what I decided to do as well. – j0e Jan 10 '14 at 07:55