【问题标题】:Rails 3.1: Couldn't find rakeRails 3.1:找不到 rake
【发布时间】:2012-02-13 11:57:44
【问题描述】:

我尝试通过 Capistrano 运行我的应用程序。我也使用:

Ubuntu 10.04.1 LTS 
Phusion Passenger 
PostgreSQL 9 
Nginx 
Rails 3.1.3 
Ruby 1.9.3

我做了之后

cap deploy:update

它创建文件夹等。

然后我在 /current 文件夹中尝试

rake RAILS_ENV=production db:schema:load

现在它显示下一个:

Could not find rake-0.9.2.2 in any of the sources
Run `bundle install` to install missing gems.

但它已安装!我试过$ bundle install$ gem update rake 没有帮助。这个错误一再出现。

$宝石列表

*** LOCAL GEMS ***

actionmailer (3.1.3)
actionpack (3.1.3)
activemodel (3.1.3)
activerecord (3.1.3)
activeresource (3.1.3)
activesupport (3.1.3)
ansi (1.4.1)
arel (2.2.1)
autotest (4.4.6)
builder (3.0.0)
bundler (1.0.21 ruby)
coffee-rails (3.1.1)
coffee-script (2.2.0)
coffee-script-source (1.2.0)
daemon_controller (0.2.6)
erubis (2.7.0)
execjs (1.2.13)
fastthread (1.0.7)
ffi (1.0.11)
gravatar_image_tag (1.0.0)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.19)
json (1.6.5)
libv8 (3.3.10.4 x86_64-linux)
mail (2.3.0)
mime-types (1.17.2)
multi_json (1.0.4)
passenger (3.0.11)
pg (0.12.2)
polyglot (0.3.3)
rack (1.3.6)
rack-cache (1.1)
rack-mount (0.8.3)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.1.3)
railties (3.1.3)
rake (0.9.2.2, 0.9.2)
rdoc (3.12)
sass (3.1.12)
sass-rails (3.1.5)
sprockets (2.0.3)
sqlite3 (1.3.5)
sys-uname (0.9.0)
texticle (2.0)
therubyracer (0.9.9)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
turn (0.8.3)
tzinfo (0.3.31)
uglifier (1.2.2)
will_paginate (3.0.2)
ZenTest (4.6.2)

$gem list rake

*** LOCAL GEMS ***

rake (0.9.2.2, 0.9.2)

这是我的 config/deploy.rb

set :user, "root"                                                             

set :rails_env, "production"

default_run_options[:pty] = true                                              
set :repository,  "git://github.com/Loremaster/sample_app.git"

set :application, "ror_tutorial"
set :deploy_to, "/vol/www/apps/#{application}"

set :scm, :git
set :branch, "master"

server "xxx.xxx.xxx.xxx", :app,
                          :web,
                          :db, :primary => true



# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
   task :start do ; end
   task :stop do ; end
   task :restart, :roles => :app, :except => { :no_release => true } do
     run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
   end
end

Capfile

load 'deploy' if respond_to?(:namespace) # cap2 differentiator

# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'

Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }

load 'config/deploy' # remove this line to skip loading any of the default tasks

UPD:我通过在 gemfile 中添加 rake gem 修复了 Rake 的错误,然后在我的本地计算机上运行 bundle install,然后通过 Capistrano 将其上传到服务器上。

【问题讨论】:

    标签: ruby-on-rails-3.1 rake capistrano ubuntu-10.04 passenger


    【解决方案1】:

    试试这个:

    RAILS_ENV=production bundle exec rake db:schema:load
    

    它需要在 bundler 的上下文中运行 rake。

    【讨论】:

    • 不,它没有帮助。 '在任何来源中都找不到 rake-0.9.2.2'
    • 您是否以您在 deploy.rb 文件中设置的同一用户(在本例中为 root)运行它?
    • 是的,我愿意!我是通过 ssh 完成的,我是“root”用户。
    【解决方案2】:

    我相信你必须以 capistrano 的身份来代替 root。试试这个:

    sudo su capistrano
    

    然后输入你的密码,然后做

    rake RAILS_ENV=production db:schema:load
    

    【讨论】:

      【解决方案3】:

      我通过在 gemfile 中添加 gem rake 来修复 Rake 的错误,然后在我的本地计算机上运行 bundle install,然后通过 Capistrano 将其上传到服务器上。

      【讨论】:

      • 我不认为这是正确的方法,尽管它可能会起作用。我在下面的回答是否有效,因为更好的方法是让 capistrano 用户成为唯一可以执行 rails 命令的用户。此外,rake 真的不应该在 gemfile 中。
      • 我的系统中没有“capistrano”这样的用户。这是第一个。每次我尝试运行 'rake RAILS_ENV=production db:schema:load' 时都会出现错误“找不到 rake”,这是第二个。
      猜你喜欢
      • 2011-10-07
      • 2016-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多