Ruby build error

ruby
rubygems

#1

All my builds are failing when circle ci tries to run
bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
It gives me the following message error:

An error occurred while installing eventmachine (1.2.3), and Bundler
cannot continue.
Make sure that gem install eventmachine -v '1.2.3' succeeds before
bundling.

To solve this I need to re-run the build without cache. Is there any other solution?


#3

This seems to be an entire class of similar issues. bundle install would fail non-deterministically for no particular reason.

When using Debug via SSH to SSH into the box, the same issue would occur, but repeatedly invoking bundle install will eventually succeed with all gems installed… So the failure is random (sometimes it’s gem X, other times it’s gem Y that fails).

Seems like a platform issue, can a CircleCI rep comment on this?


#4

Thanks @diogoribeiro! You saved my day!

Just recently, we started to see our Ruby builds failing with the exact same error message.

Rebuild without cache solved the issue as @diogoribeiro suggested.

Here’s the full error message:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/ubuntu/sharetribe/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.14/ext/ffi_c
/opt/circleci/ruby/ruby-2.3.1/bin/ruby -r ./siteconf20170411-20269-nst4mf.rb
extconf.rb
/opt/circleci/ruby/ruby-2.3.1/lib/ruby/2.3.0/rubygems/stub_specification.rb:113:in
`initialize': No such file or directory @ rb_sysopen -
/home/ubuntu/sharetribe/vendor/bundle/ruby/2.3.0/specifications/hiredis-0.6.1.gemspec
(Errno::ENOENT)
from
/opt/circleci/ruby/ruby-2.3.1/lib/ruby/2.3.0/rubygems/stub_specification.rb:113:in
`open'
from

...

Gem files will remain installed in
/home/ubuntu/sharetribe/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.14 for inspection.
Results logged to
/home/ubuntu/sharetribe/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.14/gem_make.out

An error occurred while installing ffi (1.9.14), and Bundler cannot
continue.
Make sure that `gem install ffi -v '1.9.14'` succeeds before bundling.

bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 --without=development returned exit code 5

Action failed: bundle install

Here’s the link to the build: https://circleci.com/gh/sharetribe/sharetribe/3180#tests/containers/1

Just guessing, but since we are using Ubuntu 14.04, could this be related to the latest build image update: Ubuntu 14.04 Build Image Update 201704-02 ?


#5

Facing the same issue, any gem that has a native extension may randomly fail during bundle install when a cache is present. This happens for us with bundler version 1.14.6 and ruby 2.3.4 as well as bundler 1.13.6 with ruby 2.3.1.

Oh and it started exactly 5 days ago. Everything was fine on Thu Apr 6 17:44:31 2017 +0200 then every build would fail starting from Fri Apr 7 10:26:15 2017 +0200.


#6

This issue is still persisting, and Rebuild without cache is not a permanent fix–even after the cache has been cleared and rebuilt, the issue will rear its ugly head within a few days (or hours, depending on how frequently new builds are kicked off).

If any CircleCI Staff are actually reading this forum, it’d be nice to at least get an acknowledgement of the issue.

Here’s the full stack trace I encountered this time around (the native extension that fails to compile is non-deterministic).

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/ubuntu/underwrite/vendor/bundle/ruby/2.3.0/gems/stackprof-0.2.10/ext/stackprof
/opt/circleci/ruby/ruby-2.3.1/bin/ruby -r ./siteconf20170418-15913-1p4u4fv.rb
extconf.rb
Ignoring binding_of_caller-0.7.2 because its extensions are not built.  Try: gem
pristine binding_of_caller --version 0.7.2
Ignoring byebug-5.0.0 because its extensions are not built.  Try: gem pristine
byebug --version 5.0.0
Ignoring nokogiri-1.6.6.2 because its extensions are not built.  Try: gem
pristine nokogiri --version 1.6.6.2
/opt/circleci/ruby/ruby-2.3.1/lib/ruby/2.3.0/rubygems/stub_specification.rb:148:in
`missing_extensions?': undefined method `missing_extensions?' for nil:NilClass
(NoMethodError)
from
/opt/circleci/ruby/ruby-2.3.1/lib/ruby/2.3.0/rubygems/basic_specification.rb:71:in
`contains_requirable_file?'
from
/opt/circleci/ruby/ruby-2.3.1/lib/ruby/2.3.0/rubygems/specification.rb:1037:in
`block in find_by_path'
from
/opt/circleci/ruby/ruby-2.3.1/lib/ruby/2.3.0/rubygems/specification.rb:1036:in
`each'
from
/opt/circleci/ruby/ruby-2.3.1/lib/ruby/2.3.0/rubygems/specification.rb:1036:in
`find'
from
/opt/circleci/ruby/ruby-2.3.1/lib/ruby/2.3.0/rubygems/specification.rb:1036:in
`find_by_path'
from /opt/circleci/ruby/ruby-2.3.1/lib/ruby/2.3.0/rubygems.rb:189:in
`try_activate'
from
/opt/circleci/ruby/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:125:in
`rescue in require'
from
/opt/circleci/ruby/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in
`require'
	from <internal:gem_prelude>:6:in `<internal:gem_prelude>'

extconf failed, exit code 1

Gem files will remain installed in
/home/ubuntu/underwrite/vendor/bundle/ruby/2.3.0/gems/stackprof-0.2.10 for
inspection.
Results logged to
/home/ubuntu/underwrite/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/stackprof-0.2.10/gem_make.out

An error occurred while installing stackprof (0.2.10), and Bundler
cannot continue.
Make sure that `gem install stackprof -v '0.2.10'` succeeds before bundling.

bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3  returned exit code 5

Action failed: bundle install

#7

I bumped into the same issue when trying to swith to Trusty image and Ruby 2.3.4 at the same time. Rebuidling without cache works but that as previously stated not a permanent solution.

Here the error I get:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/ubuntu/kundportalen/vendor/bundle/ruby/2.3.0/gems/json-2.0.3/ext/json/ext/parser
/opt/circleci/ruby/ruby-2.3.4/bin/ruby -r ./siteconf20170505-18297-1eqsy1d.rb
extconf.rb
Ignoring binding_of_caller-0.7.2 because its extensions are not built.  Try: gem
pristine binding_of_caller --version 0.7.2
Ignoring eventmachine-1.0.9.1 because its extensions are not built.  Try: gem
pristine eventmachine --version 1.0.9.1
Ignoring ffi-1.9.17 because its extensions are not built.  Try: gem pristine ffi
--version 1.9.17
Ignoring nio4r-1.2.1 because its extensions are not built.  Try: gem pristine
nio4r --version 1.2.1
Ignoring nokogiri-1.7.1 because its extensions are not built.  Try: gem pristine
nokogiri --version 1.7.1
Ignoring nokogiri-1.7.0.1 because its extensions are not built.  Try: gem
pristine nokogiri --version 1.7.0.1
/opt/circleci/ruby/ruby-2.3.4/lib/ruby/site_ruby/2.3.0/rubygems/stub_specification.rb:151:in
`missing_extensions?': undefined method `missing_extensions?' for nil:NilClass
(NoMethodError)
from
/opt/circleci/ruby/ruby-2.3.4/lib/ruby/site_ruby/2.3.0/rubygems/basic_specification.rb:71:in
`contains_requirable_file?'
from
/opt/circleci/ruby/ruby-2.3.4/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:1037:in
`block in find_by_path'
from
/opt/circleci/ruby/ruby-2.3.4/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:1036:in
`each'
from
/opt/circleci/ruby/ruby-2.3.4/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:1036:in
`find'
from
/opt/circleci/ruby/ruby-2.3.4/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:1036:in
`find_by_path'
from /opt/circleci/ruby/ruby-2.3.4/lib/ruby/site_ruby/2.3.0/rubygems.rb:209:in
`try_activate'
from
/opt/circleci/ruby/ruby-2.3.4/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:126:in
`rescue in require'
from
/opt/circleci/ruby/ruby-2.3.4/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in
`require'
	from <internal:gem_prelude>:6:in `<internal:gem_prelude>'

extconf failed, exit code 1

Gem files will remain installed in
/home/ubuntu/kundportalen/vendor/bundle/ruby/2.3.0/gems/json-2.0.3 for
inspection.
Results logged to
/home/ubuntu/kundportalen/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/json-2.0.3/gem_make.out

An error occurred while installing json (2.0.3), and Bundler cannot
continue.
Make sure that `gem install json -v '2.0.3'` succeeds before bundling.

bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 returned exit code 5

Action failed: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
```

This is currently my bundle config:

```
dependencies:
  pre:
    - gem uninstall bundler
    - gem install bundler
  override:
    - bundle install --path=vendor/bundle --jobs=4 --retry=3 
```

#8

The same issue and it seems that may be related to the free vs paid container as I have a feeling that it’s happening on the same one again and again. It also may be the case that it’s not enough memory on build container to perform an installation of gems with native extensions. Build without cache helps though.


#9

I apologize we never responded to this issue. Changing the ruby version on 1.0 caused the cache to become invalid due to compiled binaries. On 1.0 this would require CircleCI staff to delete the caches.

On CircleCI 2.0 this is less of a problem because you can roll your cache keys yourself. See this doc for more details https://circleci.com/docs/2.0/caching/#clearing-cache

Closing thread as 1.0 is being EOL and this issue can be self-resolved on 2.0.


#10