読者です 読者をやめる 読者になる 読者になる

元フリーエンジニアライフ

Ruby on Rails とか MovableType とかAWSやってるフリーランスウェブエンジニアの記録でした。現在は法人成りしてIT社長。

OpsWorks (Chef11) で ERROR: cannot load such file -- /var/lib/aws/opsworks/cache.stage2/cookbooks/compat_resource/files/lib/compat_resource/gemspec

いつも通りアプリのデプロイをしようとしたらエラー。

[2016-05-18T22:55:06+00:00] INFO: Loading cookbooks [apache2, apt, ark, build-essential, chef-sugar, chef_handler, compat_resource, curl, dependencies, deploy, gem_support, homebrew, mingw, mod_php5_apache2, mysql, newrelic, nginx, nodejs, opsworks, opsworks_agent_monit, opsworks_aws_flow_ruby, opsworks_bundler, opsworks_cleanup, opsworks_commons, opsworks_initial_setup, opsworks_java, opsworks_nodejs, opsworks_postgresql, opsworks_route53, opsworks_rubygems, opsworks_stack_state_sync, packages, passenger_apache2, php, python, rails, route53, ruby, s3_file, scm_helper, seven_zip, ssh_users, td-agent, test_suite, unicorn, windows, xml, yum, yum-epel]
 
================================================================================
Recipe Compile Error in /var/lib/aws/opsworks/cache.stage2/cookbooks/compat_resource/libraries/autoload.rb
================================================================================
 
 
LoadError
---------
cannot load such file -- /var/lib/aws/opsworks/cache.stage2/cookbooks/compat_resource/files/lib/compat_resource/gemspec
 
 
Cookbook Trace:
---------------
/var/lib/aws/opsworks/cache.stage2/cookbooks/compat_resource/libraries/autoload.rb:15:in `require_relative'
/var/lib/aws/opsworks/cache.stage2/cookbooks/compat_resource/libraries/autoload.rb:15:in `<top (required)>'
 
 
Relevant File Content:
----------------------
/var/lib/aws/opsworks/cache.stage2/cookbooks/compat_resource/libraries/autoload.rb:
 
8:    cookbook_version = $1
9:  
10:    if CompatResource::VERSION != cookbook_version
11:      raise "compat_resource gem version #{CompatResource::VERSION} was loaded as a gem before compat_resource cookbook version #{cookbook_version} was loaded. To remedy this, either update the cookbook to the gem version, update the gem to the cookbook version, or uninstall / stop loading the gem so early."
12:    end
13:  else
14:    # The gem is not already activated, so activate the cookbook.
15>>   require_relative '../files/lib/compat_resource/gemspec'
16:    CompatResource::GEMSPEC.activate
17:  end
18:  
19:  require 'compat_resource'
20:  
 
 
[2016-05-18T22:55:06+00:00] ERROR: Running exception handlers
[2016-05-18T22:55:06+00:00] ERROR: Exception handlers complete
[2016-05-18T22:55:06+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache.stage2/chef-stacktrace.out
[2016-05-18T22:55:06+00:00] ERROR: cannot load such file -- /var/lib/aws/opsworks/cache.stage2/cookbooks/compat_resource/files/lib/compat_resource/gemspec
[2016-05-18T22:55:06+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

解決までの経過まとめ

発覚

  • compat_resource という Chef12用のクックブックを使おうとしているみたい。ほかのコミュニティクックブックの依存がかわった?

Chef12に

Chef11のまましのぐには

  • 動いていたときと動かなくなったときの依存クックブックを比較(OpsWorksのログをみる)
  • Installing build-essential (4.0.0)これぽい
    • 依存クックブックの依存クックブック
    • 4.0.0からChef12以降専用になった
  • Berksfileで動いていたときのバージョン(3.2.0)に固定
cookbook 'build-essential', '3.2.0'

再デプロイ

古いバージョン固定なので、いずれ腐ってきてどうにもならなくなったときつらそうだが、当面はこれで・・・