cjhin
cjhin

Reputation: 235

Rake commands not recognized

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!

Upvotes: 2

Views: 8553

Answers (2)

cjhin
cjhin

Reputation: 235

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!

Upvotes: 0

BvuRVKyUVlViVIc7
BvuRVKyUVlViVIc7

Reputation: 11811

Did you try it via bundle?

bundle exec rake db:migrate

Upvotes: 2

Related Questions