命令:rails console,生成无法识别.错误:命令'rails'无法识别用法:rails命令[ARGS]

tru*_*gnm 2 ruby windows ubuntu ruby-on-rails

当我进入rails文件夹(我在我的rails app文件夹中)并键入"rails c"或"rails g"时,它说:

错误:无法识别命令"rails"

用法:rails COMMAND [ARGS]

Usage: spring COMMAND [ARGS]                                                                                                                     

Commands for spring itself:                                                                                                                      

  binstub         Generate spring based binstubs. Use --all to generate a binstub for all known commands. Use --remove to revert.                
  help            Print available commands.                                                                                                      
  server          Explicitly start a Spring server in the foreground                                                                             
  status          Show current status.                                                                                                           
  stop            Stop all spring processes for this project.                                                                                    

Commands for your application:                                                                                                                   

  rails           Run a rails command. The following sub commands will use spring: console, runner, generate, destroy, test.                     
  rake            Runs the rake command                                                                                                          
Error: Command 'rails' not recognized                                                                                                            
Usage: rails COMMAND [ARGS]                                                                                                                      

The most common rails commands are:                                                                                                              
 generate    Generate new code (short-cut alias: "g")                                                                                            
 console     Start the Rails console (short-cut alias: "c")                                                                                      
 server      Start the Rails server (short-cut alias: "s")                                                                                       
 dbconsole   Start a console for the database specified in config/database.yml                                                                   
             (short-cut alias: "db")                                                                                                             
 new         Create a new Rails application. "rails new my_app" creates a                                                                        
             new application called MyApp in "./my_app"                                                                                          

In addition to those, there are:                                                                                                                 
 destroy      Undo code generated with "generate" (short-cut alias: "d")                                                                         
 plugin new   Generates skeleton for developing a Rails plugin                                                                                   
 runner       Run a piece of code in the application environment (short-cut alias: "r")                                                          

All commands can be run with -h (or --help) for more information.
Run Code Online (Sandbox Code Playgroud)

我正在运行适用于Windows 10的Linux子系统,我知道我知道你看到了Windows但它有点...... Linux,我通过本教程安装了rbenv的Ruby .

J F*_*ier 6

从您的app文件夹中尝试此命令:

rake rails:update:bin
Run Code Online (Sandbox Code Playgroud)

说y替换二进制文件.

我在Windows Linux子系统中使用rails时遇到了同样的问题.我在这里找到了这个建议:

Rails命令错误

我尝试了它,它解决了我的问题,所以也许你的问题.