Rails 5.1,Errno :: EMFILE:太多打开的文件 - getcwd

时间:2017-09-18 14:46:05

标签: ruby-on-rails ruby carrierwave factory-bot

在运行整个/ spec目录的过去几天,我开始看到这个错误。我怀疑它是否揭示了我的测试状态 - 它是随机发生的。我的预感是 Errno::EMFILE: Too many open files - getcwd # /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/sanitized_file.rb:115:in `expand_path' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/sanitized_file.rb:115:in `path' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/sanitized_file.rb:146:in `exists?' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/sanitized_file.rb:95:in `size' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/sanitized_file.rb:137:in `empty?' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/uploader/cache.rb:131:in `cache!' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/mount.rb:329:in `cache' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-0.11.2/lib/carrierwave/mount.rb:163:in `attachment=' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/carrierwave-base64-2.5.3/lib/carrierwave/base64/adapter.rb:26:in `block in mount_base64_uploader' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `public_send' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `each' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `tap' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:12:in `object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:9:in `result' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory.rb:42:in `run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:29:in `block in run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.2/lib/active_support/notifications.rb:168:in `instrument' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:28:in `run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:5:in `association' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:33:in `association' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute/association.rb:19:in `block in to_proc' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `instance_exec' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `block in define_attribute' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:56:in `get' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `each' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `tap' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:12:in `object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:9:in `result' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory.rb:42:in `run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:29:in `block in run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.2/lib/active_support/notifications.rb:168:in `instrument' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:28:in `run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:5:in `association' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:33:in `association' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute/association.rb:19:in `block in to_proc' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `instance_exec' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `block in define_attribute' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:56:in `get' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `each' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `tap' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:12:in `object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:9:in `result' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory.rb:42:in `run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:29:in `block in run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.2/lib/active_support/notifications.rb:168:in `instrument' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:28:in `run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:5:in `association' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:33:in `association' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute/association.rb:19:in `block in to_proc' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `instance_exec' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `block in define_attribute' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:56:in `get' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `each' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `tap' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:12:in `object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:9:in `result' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory.rb:42:in `run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:29:in `block in run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.2/lib/active_support/notifications.rb:168:in `instrument' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:28:in `run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:5:in `association' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:33:in `association' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute/association.rb:19:in `block in to_proc' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `instance_exec' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluator.rb:77:in `block in define_attribute' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:56:in `get' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `each' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `tap' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/attribute_assigner.rb:14:in `object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:12:in `object' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:9:in `result' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory.rb:42:in `run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:29:in `block in run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.2/lib/active_support/notifications.rb:168:in `instrument' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:28:in `run' # /Users/fred/.rvm/gems/ruby-2.4.1/gems/factory_girl-4.8.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method' 可能是配置问题。

  config.use_transactional_fixtures = false
  config.before(:each) do
    Sidekiq::Worker.clear_all
  end

  config.before(:suite) do
    DatabaseCleaner.clean_with(:truncation)
    RedisCache.new.flushdb
  end

  config.before(:each) do
    DatabaseCleaner.strategy = :transaction
  end

  config.before(:each) do
    DatabaseCleaner.start
  end

  config.after(:each) do
    DatabaseCleaner.clean
  end

堆栈跟踪始终相同。我无法在我的代码中明确地看到打开文件的位置。

我最近使用以下选项实现了DatabaseCleaner:

$urlRouterProvider.otherwise(function () {
    var items = window.localStorage.getItem('username');
    if (items === undefined || items === null || items.length === 0) {


        return '/app/login';


    }
    else {


        return '/app/search';


    }


});

1 个答案:

答案 0 :(得分:0)

他们将此问题与Carrierwave 0.5.8相关联。

post是从2012年3月14日开始的,所以肯定是过时的

  

我可以确认直到0.5.7的载波正常工作。只有0.5.8会导致此问题。我将在今晚晚些时候在carrierwave中打开一个问题。

但你有Carrierwave 0.11.2