[英]Don't know how to build task 'rails'
我正在關注Ruby on Rails教程(Rails 5)使用rails 5.0.0.1學習使用Rails的Web開發Michael Hartl,當我嘗試在bash中運行以下命令時
rails generate scaffold User name:string email:string
我收到了這個錯誤
Version: 1.7.2
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
rails aborted!
Don't know how to build task 'rails' (see --tasks)
/home/Medo/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:13:in `block in run_rake_task'
/home/Medo/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:10:in `run_rake_task'
/home/Medo/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/home/Medo/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
(See full trace by running task with --trace)
我不知道是什么導致了這個問題,並且在搜索一小時之后無法看到它的解決方案。
那么這對我有用
bundle install --binstubs
在它之后,導軌工作沒有問題
這有助於我們。 我只是運行這3個命令,它的工作。
看起來你的應用程序的./bin/rails是由Bundler生成的存根。
在Rails 5中,您的應用程序的bin /目錄包含與任何其他源代碼一樣版本化的可執行文件,而不是按需生成的存根。
以下是升級方法:
bundle config --delete bin#關閉Bundler的存根生成器
rails app:update:bin#使用新的Rails 5可執行文件
git add bin#添加bin /到源代碼控制您可能還需要從.gitignore中刪除bin /。
我不確定,但也許它可以提供幫助
$ spring stop
$ rails generate scaffold User name:string email:string
你能檢查一下導軌是否正常工作。也可以試試
bin/rails generate scaffold User name:string email:string
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.