【问题标题】:How to build task 'gems:install'如何构建任务“宝石:安装”
【发布时间】:2009-11-20 11:26:10
【问题描述】:

我正在将我的 rails 应用程序部署到 linux 服务器,但我缺少一些 rake 任务,包括 rake gems:install 和 rake db

我正在运行 GEM 的 rails 2.3.4。

这是为什么?

我该如何解决这个问题?我可以以某种方式更新吗?


rake -T 列表中缺少它们

rake apache2                   # Build Apache 2 module
rake clean                     # Remove compiled files
rake clobber                   # Remove all generated files
rake default                   # Build everything
rake doc                       # Generate all documentation
rake doxygen                   # Generate Doxygen C++ API documentation if ...
rake doxygen:clobber           # Remove generated Doxygen C++ API documenta...
rake doxygen:force             # Force generation of Doxygen C++ API docume...
rake fakeroot                  # Create a fakeroot, useful for building nat...
rake nginx                     # Build Nginx helper server
rake package                   # Build all the packages
rake package:clean             # Remove package products
rake package:debian            # Create a Debian package
rake package:force             # Force a rebuild of the package files
rake package:gem               # Build the gem file passenger-2.2.4.gem
rake rdoc                      # Build the rdoc HTML Files
rake rdoc:clobber              # Remove rdoc products
rake rdoc:force                # Force a rebuild of the RDOC files
rake sloccount                 # Run 'sloccount' to see how much code Passe...
rake test                      # Run all unit tests and integration tests
rake test:cxx                  # Run unit tests for the Apache 2 and Nginx ...
rake test:integration          # Run all integration tests
rake test:integration:apache2  # Run Apache 2 integration tests
rake test:integration:nginx    # Run Nginx integration tests
rake test:oxt                  # Run unit tests for the OXT library
rake test:rcov                 # Run coverage tests for the Ruby libraries
rake test:restart              # Run the 'restart' integration test infinit...
rake test:ruby                 # Run unit tests for the Ruby libraries

我的 rake 文件包含以下内容:

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

require 'tasks/rails'

如何添加 gems 和 db rake 任务?为什么他们失踪了?

【问题讨论】:

    标签: ruby-on-rails linux deployment rubygems capistrano


    【解决方案1】:

    rake -T 的输出是什么?这应该列出所有可用的任务。在 RoR 应用程序中,Rakefile 定义了您的任务。

    您可以使用 gem update 更新 gem。

    【讨论】:

      【解决方案2】:

      检查您的 Capfile,如果您实际上是从 Capistrano 运行 gems:install。显然,这样做的方法是确保您在运行 Capistrano 时位于正确的内部目录中。

      namespace :gems do
        desc "Install gems"
        task :install, :roles => :app do
          run "cd #{current_path} && #{sudo} rake RAILS_ENV=production gems:install"
        end
      end
      

      您也可以始终指定 Rakefile 以确保在 rake 命令前使用 -f [FILE] 选项。

      【讨论】:

        【解决方案3】:

        您可以尝试更新您的 Rails 安装,或者通过传递 --force 标志来重新安装 Rails。您还有其他项目可以使用此命令吗?检查这些项目的 rake 文件。看起来你的 rakefile 和我的一样……这个项目最初是基于旧版本的 rails 吗?您正在运行什么 Gem 版本?您可能需要做一个gem update --system。这些都是可能的。

        【讨论】:

        • 嗨卢卡斯我刚刚运行 gem install rails --no-ri --no-rdoc --force 但仍然缺少 rake 任务 db 和 gems 等我然后运行 ​​gem update --system 和它说没什么要更新的。是的,这个项目最初基于 rails 2.3.3,但已更新到 2.3.4,并且在供应商中没有任何东西从 GEM 运行。有任何想法吗 ?非常感谢
        • 刚刚在我的服务器上创建了一个新的 Rails 应用程序,其中包含所有 rake 任务。怎么回事!!!!!!
        • 刚刚注意到您的问题用 capistrano 标记。可能会检查以确保 cap 没有在未连接到 rails 的情况下定义自己的 rake 任务。
        【解决方案4】:

        我想你总是可以重新创建你的项目。烦人,但似乎总是有助于最坏的情况。

        至少这会让你知道它是项目还是某种依赖问题。

        【讨论】:

          【解决方案5】:

          如果您使用的是 rails 应用程序,您还可以在 lib/tasks/SOME_TASK.rake 中定义 rake 任务

          如果你定义了 SOME_TASK,它会在你运行 rake -T 时显示出来,并且是一个可用的命令。

          【讨论】:

            猜你喜欢
            • 2017-08-10
            • 1970-01-01
            • 2011-01-25
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2016-03-23
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多