Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails command Error

Im about to start work on another web application, I change directories to

/rails_projects

and enter

rails new blank

I then get this error

Error: Command not recognized
Usage: rails COMMAND [ARGS]

The common rails commands available for engines are:
 generate    Generate new code (short-cut alias: "g")
 destroy     Undo code generated with "generate" (short-cut alias: "d")

All commands can be run with -h for more information.

If you want to run any commands that need to be run in context
of the application, like `rails server` or `rails console`,
you should do it from application's directory (typically test/dummy).

I have reinstalled rails, and still same error, any ideas?

UPDATE:

It actually give me the same error when I type just

rails -h

rails

in cmd

like image 518
Seal Avatar asked Feb 09 '26 18:02

Seal


2 Answers

For anyone with a similar error that may land here, this fixed it for me:

rake rails:update:bin

This will generate "new" versions of the binaries. Just say Yes when it inquires you to replace them.

like image 153
dev404 Avatar answered Feb 12 '26 07:02

dev404


I ran into a similar issue when trying to upgrade a Rails Engine from 3.2 to 4.1.

The culprit was the presence of script/rails which contained:

#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/my_project/engine', __FILE__)

require 'rails/all'
require 'rails/engine/commands'

The problem line is there at the end: require 'rails/engine/commands. That was not allowing the full Rails CLI to load which omitted the new command. Removing that file solved my problem.

I'm pretty sure this wasn't the cause of your specific problem, but the symptoms were the same as mine and this was the first link in Google for the error message. Just passing along my findings to help anyone else that runs into this same situation.

like image 37
oif_vet Avatar answered Feb 12 '26 07:02

oif_vet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!