Comments (9)
ChefSpec is doing a simple require 'berkshelf'
and then rescuing the LoadError
from chef-dk.
Does that mean that I additionally need to install berkshelf as a Gem, even though it comes with ChefDK pre-bundled already?
from chef-dk.
Berkshelf is installed as a gem into ChefDK. For example, this works for me (on mac):
$ /opt/chefdk/embedded/bin/gem which berkshelf
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-3.1.3/lib/berkshelf.rb
$ /opt/chefdk/embedded/bin/ruby -e 'require "berkshelf"; p Berkshelf::VERSION'
"3.1.3"
So I'm not sure what's going on. Can you reproduce this error if ChefDK is installed to the default location? Is there any bundler or anything else involved that could be affecting this?
from chef-dk.
Same for me:
D:\Repos\_github\bills-kitchen\target\build\repo\tmp2>gem which berkshelf
D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/gems/2.0.0/gems/berkshelf-3.1.3/lib/berkshelf.rb
D:\Repos\_github\bills-kitchen\target\build\repo\tmp2>ruby -e 'require "berkshelf"; p Berkshelf::VERSION'
DL is deprecated, please use Fiddle
"3.1.3"
The problem is when adding a chefspec example that requires berkshelf, e.g. with spec/foo_spec.rb
:
require 'chefspec'
require 'chefspec/berkshelf'
describe "foo" do
it "compares numbers" do
expect(1 == 1).to be true
end
end
Running rspec
will now produce the above mentioned error due to the require 'chefspec/berkshelf'
.
from chef-dk.
Btw: I have also tried adding both chefspec and berkshelf to a Gemfile, but they seem to conflict :-(
Gemfile:
source 'https://rubygems.org'
gem 'berkshelf', '3.1.3'
gem 'chefspec', '4.0.0'
Output:
D:\Repos\_github\bills-kitchen\target\build\repo\tmp>bundle install
DL is deprecated, please use Fiddle
Fetching gem metadata from https://rubygems.org/........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "ffi":
In Gemfile:
berkshelf (= 3.1.3) x86-mingw32 depends on
ffi (~> 1.9) x86-mingw32
chefspec (= 4.0.0) x86-mingw32 depends on
ffi (1.5.0)
from chef-dk.
@tknerr that's probably the root cause of your original issue. Can you try running with ruby -d
? That will show all exceptions (including ones that get rescued). You'll see a lot of irrelevant exceptions, but you should get the full message of the Gem::LoadError
that happens right before chefspec finally fails.
For example:
$ ruby -e "raise 'foo' rescue nil"
$ ruby -d -e "raise 'foo' rescue nil"
Exception `LoadError' at /Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/rubygems.rb:1082 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Users/ddeleo/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/rubygems.rb:1091 - cannot load such file -- rubygems/defaults/ruby
Exception `RuntimeError' at -e:1 - foo
I'll guess that this issue is caused by chef pinning its FFI dependency to an older version. If that is indeed the problem, it will be fixed soon. See: chef/chef#1528
from chef-dk.
@danielsdeleo guess you are right, should probably be fixed with chef/chef#1528
Here's the output of ruby -d -e 'require "chefspec"; require "chefspec/berkshelf"'
:
D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55: warning: loading in progress, circular require considered harmful - D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/gems/2.0.0/gems/chef-11.14.0.alpha.5-x86-mingw32/lib/chef/resource/windows_package.rb
from -e:1:in `<main>'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/gems/2.0.0/gems/chefspec-4.0.0/lib/chefspec.rb:24:in `<top (required)>'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/gems/2.0.0/gems/chefspec-4.0.0/lib/chefspec.rb:24:in `require_relative'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/gems/2.0.0/gems/chefspec-4.0.0/lib/chefspec/api.rb:1:in `<top (required)>'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/gems/2.0.0/gems/chefspec-4.0.0/lib/chefspec/api.rb:1:in `require_relative'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/gems/2.0.0/gems/chefspec-4.0.0/lib/chefspec/runner.rb:5:in `<top (required)>'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/gems/2.0.0/gems/chef-11.14.0.alpha.5-x86-mingw32/lib/chef/resources.rb:72:in `<top (required)>'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/gems/2.0.0/gems/chef-11.14.0.alpha.5-x86-mingw32/lib/chef/resource/windows_package.rb:20:in `<top (required)>'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/gems/2.0.0/gems/chef-11.14.0.alpha.5-x86-mingw32/lib/chef/provider/package/windows.rb:19:in `<top (required)>'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
Exception `LoadError' at D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55 - cannot load such file -- berkshelf
Exception `Gem::LoadError' at D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/specification.rb:2007 - Unable to activate dep_selector-1.0.3, because ffi-1.5.0-x86-mingw32 conflicts with ffi (~> 1.9)
Exception `Gem::LoadError' at D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/specification.rb:2007 - Unable to activate dep_selector-1.0.3, because ffi-1.5.0-x86-mingw32 conflicts with ffi (~> 1.9)
Exception `ChefSpec::Error::GemLoadError' at D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/gems/2.0.0/gems/chefspec-4.0.0/lib/chefspec/berkshelf.rb:4 - I could not load the 'Berkshelf' gem! You must have the gem installed
on your local system before you can use the berkshelf plugin.
You can install berkshelf by running:
gem install berkshelf
or add Berkshelf to your Gemfile and
Relevant lines:
Exception `LoadError' at D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55 - cannot load such file -- berkshelf
Exception `Gem::LoadError' at D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/specification.rb:2007 - Unable to activate dep_selector-1.0.3, because ffi-1.5.0-x86-mingw32 conflicts with ffi (~> 1.9)
Exception `Gem::LoadError' at D:/Repos/_github/bills-kitchen/target/build/tools/chefdk/embedded/lib/ruby/2.0.0/rubygems/specification.rb:2007 - Unable to activate dep_selector-1.0.3, because ffi-1.5.0-x86-mingw32 conflicts with ffi (~> 1.9)
from chef-dk.
Okay, gonna close this as a duplicate in that case. The relevant fix should be released as an updated alpha as soon as we verify things with the new ffi version in our build lab.
from chef-dk.
@danielsdeleo cool stuff, let me know when a new alpha build is available
from chef-dk.
Related Issues (20)
- Gemfile.lock in Working Directory Causes Bundler version error HOT 3
- inspec bug in chefdk 4.4.14 HOT 10
- Omnibus and Hab appbundling are not the same HOT 1
- Dependabot can't resolve your Ruby dependency files HOT 2
- Dependabot can't resolve your Ruby dependency files HOT 2
- Improve test execution times with a pre-warmed docker image HOT 1
- Ship DK 3 for Oct HOT 1
- Ship DK 4 for Oct HOT 1
- Release DK 3 to resolve libxslt CVE HOT 1
- Cookbook generators failed to generate new cookbooks -- undefined method `metadata' HOT 2
- Release Chef-DK 4.6 HOT 1
- Release DK for December HOT 1
- policyfile checksum keeps changing HOT 2
- Your .dependabot/config.yml contained invalid details HOT 1
- Release DK for Feb HOT 1
- Fix ChefDK 3 build pipeline
- DK release notes are not up to date on docs.chef.io HOT 2
- Any Documentation/script to remove chefdk from linux system? HOT 4
- Generate Policyfile.lock.json without Kitchen Test HOT 1
- Running chef-zero/chef-solo on chef server itself.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chef-dk.