无法执行“rails db:*”之类的命令
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法执行“rails db:*”之类的命令相关的知识,希望对你有一定的参考价值。
我目前正在使用Ruby on rails写一个网站几个月。
突然(5或6天前),所有的命令,如rails db:migrate
,rails db:rollback
,rails db:*
“不再起作用了(它似乎没有触及任何东西......)。
我试图重新安装宝石rake
,rails
和railsties
(已经在他们的最新版本中),但问题仍然存在。
执行命令rails db:migrate
时的结果:
rails aborted!
Don't know how to build task 'db:migrate' (See the list of available tasks with `rake --tasks`)
/usr/local/rvm/gems/ruby-2.5.1/gems/railties-5.2.2/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/usr/local/rvm/gems/ruby-2.5.1/gems/railties-5.2.2/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/usr/local/rvm/gems/ruby-2.5.1/gems/railties-5.2.2/lib/rails/command.rb:48:in `invoke'
/usr/local/rvm/gems/ruby-2.5.1/gems/railties-5.2.2/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
(See full trace by running task with --trace)
执行命令rake db:migrate
时的结果:
rake aborted!
Don't know how to build task 'db:migrate' (See the list of available tasks with `rake --tasks`)
/usr/local/rvm/gems/ruby-2.5.1/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in `eval'
/usr/local/rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in `<main>'
(See full trace by running task with --trace)
执行命令rails --tasks --all
时的结果:
rails app:template # Applies the template supplied by LOCATION=(/path/t...
rails app:templates:copy #
rails app:update # Update configs and some other initially generated ...
rails app:update:bin #
rails app:update:configs #
rails app:update:upgrade_guide_info #
rails assets:clean[keep] # Remove old compiled assets
rails assets:clobber # Remove compiled assets
rails assets:environment # Load asset compile environment
rails assets:precompile # Compile all the assets named in config.assets.prec...
rails autoprefixer:info # Show selected browsers and prefixed CSS properties...
rails cache_digests:dependencies # Lookup first-level dependencies for TEMPLATE (like...
rails cache_digests:nested_dependencies # Lookup nested dependencies for TEMPLATE (like mess...
rails default #
rails dev:cache # Toggle development mode caching on/off
rails environment #
rails initializers # Print out all defined initializers in the order th...
rails log:clear # Truncates all/specified *.log files in log/ to zer...
rails middleware # Prints out your Rack middleware stack
rails notes # Enumerate all annotations (use notes:optimize, :fi...
rails notes:custom # Enumerate a custom annotation, specify with ANNOTA...
rails notes:fixme #
rails notes:optimize #
rails notes:todo #
rails restart # Restart app by touching tmp/restart.txt
rails routes # Print out all defined routes in match order, with ...
rails secret # Generate a cryptographically secure secret key (th...
rails stats # Report code statistics (KLOCs, etc) from the appli...
rails test # Runs all tests in test folder except system ones
rails test:controllers #
rails test:db # Run tests quickly, but also reset db
rails test:functionals #
rails test:generators #
rails test:helpers #
rails test:integration #
rails test:jobs #
rails test:mailers #
rails test:models #
rails test:prepare #
rails test:run #
rails test:system # Run system tests only
rails test:units #
rails time:zones[country_or_offset] # List all time zones, list by two-letter country co...
rails time:zones:all #
rails time:zones:local #
rails time:zones:us #
rails tmp #
rails tmp/cache #
rails tmp/cache/assets #
rails tmp/pids #
rails tmp/sockets #
rails tmp:cache:clear #
rails tmp:clear # Clear cache, socket and screenshot files from tmp/...
rails tmp:create # Creates tmp directories for cache, sockets, and pids
rails tmp:pids:clear #
rails tmp:screenshots:clear #
rails tmp:sockets:clear #
rails yarn:install # Install all javascript dependencies as specified v...
如果你能帮我解决这个问题,我将非常感激!
先感谢您 !
奥勒留
这可能是由于ruby版本升级所致。尝试使用bundle install
再次安装宝石,然后再试一次。如果不工作,你需要运行bundle exec rails db:migrate
捆绑选择正确版本的宝石。
编辑:因为你正在使用rvm,请确保你使用相同的Ruby版本。看看这个https://rvm.io/workflow/projects并确保你的版本正确。提示:检查Gemfile中的Ruby版本,因为它可能是您的问题的根源。
以上是关于无法执行“rails db:*”之类的命令的主要内容,如果未能解决你的问题,请参考以下文章
Rails db:schema:load 错误:Mysql2::Error:无法删除或更新父行:外键约束失败
无法找到指定dll库文件skinH_EL.dll中的输出命令skinH_Attach_EX_
ViewPager 之类的东西在 Android TV 的浏览器片段中
命令对可执行文件执行右键单击操作并选择“使用图形处理器运行”之类的选项
java.lang.IllegalStateException:onSaveInstanceState On Activity Backpress 后无法执行此操作(不使用任何片段)