chef / libyajl2-gem

gem to install the libyajl2 c-library for distributions which do not have it
Apache License 2.0
1 stars 15 forks source link

Uninformative error message during build when `make` is not installed #25

Open sparr opened 4 years ago

sparr commented 4 years ago

Describe the problem

When trying to install this gem without make installed, an unhelpful error message is produced that requires looking at the gem source to figure out.

Software Version

1.2.0 Ubuntu 20.04

Replication Case

gem install libyajl2

Stacktrace

error message during a slightly more involved attempt to install than the simple case above ``` Installing libyajl2 1.2.0 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /home/ubuntu/src/better-chef-rundeck/vendor/bundle/ruby/2.5.0/gems/libyajl2-1.2.0/ext/libyajl2 /usr/bin/ruby2.5 -r ./siteconf20201009-12357-1c5mlj.rb extconf.rb creating Makefile /home/ubuntu/src/better-chef-rundeck/vendor/bundle/ruby/2.5.0/gems/libyajl2-1.2.0/ext/libyajl2 extconf.rb:104:in `makemakefiles': unhandled exception from extconf.rb:138:in `
' extconf failed, exit code 1 Gem files will remain installed in /home/ubuntu/src/better-chef-rundeck/vendor/bundle/ruby/2.5.0/gems/libyajl2-1.2.0 for inspection. Results logged to /home/ubuntu/src/better-chef-rundeck/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/libyajl2-1.2.0/gem_make.out An error occurred while installing libyajl2 (1.2.0), and Bundler cannot continue. Make sure that `gem install libyajl2 -v '1.2.0'` succeeds before bundling. In Gemfile: chef was resolved to 13.6.4, which depends on chef-zero was resolved to 13.1.0, which depends on ffi-yajl was resolved to 2.3.1, which depends on libyajl2 ```

Possible Solution

adsk-stoddai commented 2 years ago

If an embedded chef gem requires FFI, you will have to ensure your environment already has make/gcc tools installed (like build-essential on Ubuntu).

OS packages normally install during Chef's 2nd stage (converge), so make/gcc might not be available during Chef's 1st stage (compile), which might happen if something like Test Kitchen tries to install libyajl2 during a compile phase (or before build packages are available).

If you have gems that need to be added to Chef's embedded library, and participate in the compile phase, you likely have three options: