Capifony数据库函数失败并出现`require':无法加载此类文件 - FileUtils(LoadError)

时间:2012-04-11 14:53:37

标签: ruby symfony rvm capifony

当我调用任何Capifony数据库函数时,例如cap database:move:to_remote,我收到以下ruby错误:

jeremykendall@isr-thinkpad-420s:~/dev/sites/app$ cap develop database:move:to_remote
    triggering load callbacks
* executing `develop'
    triggering start callbacks for `database:move:to_remote'
* executing `multistage:ensure'
* executing `database:move:to_remote'
* executing `database:dump:local'
/home/jeremykendall/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- FileUtils (LoadError)
        from /home/jeremykendall/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capifony-2.1.5/lib/symfony2.rb:101:in `block (3 levels) in load'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:139:in `instance_eval'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:139:in `invoke_task_directly'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:89:in `execute_task'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/configuration/namespaces.rb:110:in `block in define_task'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capifony-2.1.5/lib/symfony2.rb:159:in `block (3 levels) in load'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:139:in `instance_eval'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:139:in `invoke_task_directly'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:89:in `execute_task'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:101:in `find_and_execute_task'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:46:in `block in execute_requested_actions'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:45:in `each'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:45:in `execute_requested_actions'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/cli/help.rb:19:in `execute_requested_actions_with_help'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:34:in `execute!'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:14:in `execute'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/gems/capistrano-2.11.2/bin/cap:4:in `<top (required)>'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/bin/cap:19:in `load'
        from /home/jeremykendall/.rvm/gems/ruby-1.9.3-p125@interperf/bin/cap:19:in `<main>'

我的deploy.rb:

set :stage_dir,       'app/config/deploy'
require 'capistrano/ext/multistage'
set :stages,          %w{production testing develop}

default_run_options[:pty] = true

set :application,     "appname"
set :deploy_to,       "/home/isr/sites/app"
set :deploy_via,      :remote_cache

set :scm,             :git
set :repository,      "git@github.com:jeremykendall/redacted.git"
set :user,            "isr"
set :use_sudo,        false

ssh_options[:forward_agent] = true

set :model_manager,   "doctrine"
set :keep_releases,   3
set :update_vendors,  true
set :shared_files,    ["app/config/parameters.yml", "app/config/parameters.ini"]
set :shared_children, [app_path + "/logs", app_path + "/cache", web_path + "/uploads", "vendor"]

我的app / config / deploy / develop.rb

# Deploys to local vagrant box

set  :domain,           "192.168.33.10"
set  :symfony_env_prod, "dev"
set  :deploy_to,        "/home/vagrant/sites/app"
set  :branch,           "develop"
set  :user,             "vagrant"

role :web,              domain                   # Your HTTP server, Apache/etc
role :app,              domain                   # This may be the same as your `Web` server
role :db,               domain, :primary => true # This is where Rails migrations will run

我尝试过什么

  • gem install fileutils
  • sudo aptitude install libfileutils-ocaml-dev(抓住FileUtils吸管)
  • gem update --system
  • gem update

5 个答案:

答案 0 :(得分:9)

看起来像是a bug in capifony 2.1.5。尝试点击require "FileUtils"并替换为require "fileutils"。那还是等待补丁?

答案 1 :(得分:4)

您会发现require 'FileUtils'通常适用于Mac OS X,但它应该是小写的fileutils。问题是,大多数人使用Mac OS X时不区分大小写的文件系统,因此当您部署或移动到Linux或其他文件系统(如ZFS)时,如果启用了区分大小写,则会失败。

答案 2 :(得分:2)

由于FileUtils是corelib的一部分,所以它应该存在于任何ruby安装中,前提是它可以在使用RVM安装ruby时编译它。我自己也遇到过类似的问题,其中一些不存在,但事实证明,当我用RVM编译ruby时,我没有安装一些依赖项。

这些是所有ruby corelib功能的全部要求加上RVM要求的一对。 (使用rvm requirements

找到
apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core  zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev  autoconf libc6-dev ncurses-dev automake libtool bison subversion

现在,完全删除ruby和源然后重新安装。 (否则,以前的配置选项可能无法取消设置并将您留在同一位置)

rvm reinstall 1.9.3-p125

答案 3 :(得分:0)

我在另一个晚上尝试使用gem安装rails时遇到了类似的错误,事实证明我错误地信任apt-get来获取我需要的所有内容。

我敢打赌,在安装软件包并确保它们实际上是你想要的时候,你会比我更谨慎,但这是我安装的(大致)修复它。

sudo apt-get install ruby-full build-essential

sudo aptitude install ruby build-essential libopenssl-ruby ruby1.8-dev

答案 4 :(得分:0)

您有一个用于symphony部署的gem,它会自动添加到您的部署中:

gem uninstall capifony

使用gemsetsbundler exec capistrano ...来解决此问题