Error creating project in Ubuntu Container

I’m not able to create project without this error when using Ubuntu image of Terraspace.

=> Creating new project called infra.
=> Installing dependencies with: bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root
will break this application for all non-root users on this machine.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    current directory: /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/racc-1.5.2/ext/racc/cparse
/opt/terraspace/embedded/bin/ruby -I /opt/terraspace/embedded/lib/ruby/2.7.0 -r
./siteconf20210817-71-5iz1ye.rb extconf.rb
checking for rb_ary_subseq()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
/opt/terraspace/embedded/lib/ruby/2.7.0/mkmf.rb:482:in `try_do': The compiler failed to generate an
executable file. (RuntimeError)
You have to install development tools first.
	from /opt/terraspace/embedded/lib/ruby/2.7.0/mkmf.rb:575:in `try_link0'
	from /opt/terraspace/embedded/lib/ruby/2.7.0/mkmf.rb:593:in `try_link'
	from /opt/terraspace/embedded/lib/ruby/2.7.0/mkmf.rb:805:in `try_func'
	from /opt/terraspace/embedded/lib/ruby/2.7.0/mkmf.rb:1094:in `block in have_func'
	from /opt/terraspace/embedded/lib/ruby/2.7.0/mkmf.rb:982:in `block in checking_for'
	from /opt/terraspace/embedded/lib/ruby/2.7.0/mkmf.rb:361:in `block (2 levels) in postpone'
	from /opt/terraspace/embedded/lib/ruby/2.7.0/mkmf.rb:331:in `open'
	from /opt/terraspace/embedded/lib/ruby/2.7.0/mkmf.rb:361:in `block in postpone'
	from /opt/terraspace/embedded/lib/ruby/2.7.0/mkmf.rb:331:in `open'
	from /opt/terraspace/embedded/lib/ruby/2.7.0/mkmf.rb:357:in `postpone'
	from /opt/terraspace/embedded/lib/ruby/2.7.0/mkmf.rb:981:in `checking_for'
	from /opt/terraspace/embedded/lib/ruby/2.7.0/mkmf.rb:1093:in `have_func'
	from extconf.rb:6:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:


extconf failed, exit code 1

Gem files will remain installed in /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/racc-1.5.2 for
Results logged to

  /opt/terraspace/embedded/lib/ruby/2.7.0/rubygems/ext/builder.rb:99:in `run'
  /opt/terraspace/embedded/lib/ruby/2.7.0/rubygems/ext/ext_conf_builder.rb:48:in `block in build'
  /opt/terraspace/embedded/lib/ruby/2.7.0/tempfile.rb:291:in `open'
  /opt/terraspace/embedded/lib/ruby/2.7.0/rubygems/ext/ext_conf_builder.rb:30:in `build'
  /opt/terraspace/embedded/lib/ruby/2.7.0/rubygems/ext/builder.rb:169:in `block in build_extension'
  /opt/terraspace/embedded/lib/ruby/2.7.0/rubygems/ext/builder.rb:165:in `synchronize'
  /opt/terraspace/embedded/lib/ruby/2.7.0/rubygems/ext/builder.rb:165:in `build_extension'
  /opt/terraspace/embedded/lib/ruby/2.7.0/rubygems/ext/builder.rb:210:in `block in build_extensions'
  /opt/terraspace/embedded/lib/ruby/2.7.0/rubygems/ext/builder.rb:207:in `each'
  /opt/terraspace/embedded/lib/ruby/2.7.0/rubygems/ext/builder.rb:207:in `build_extensions'
  /opt/terraspace/embedded/lib/ruby/2.7.0/rubygems/installer.rb:844:in `build_extensions'
`block in worker_pool'
/opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.25/lib/bundler/worker.rb:57:in `block in
  /opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.25/lib/bundler/worker.rb:54:in `loop'
/opt/terraspace/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.2.25/lib/bundler/worker.rb:91:in `block (2
levels) in create_threads'

e[0me[31mAn error occurred while installing racc (1.5.2), and Bundler cannot continue.e[0m

In Gemfile:
  terraspace was resolved to 0.6.13, which depends on
    terraspace_plugin_azurerm was resolved to 0.3.1, which depends on
      azure-storage-blob was resolved to 1.1.0, which depends on
        azure-storage-common was resolved to 1.1.0, which depends on
          azure-core was resolved to 0.1.15, which depends on
            nokogiri was resolved to 1.12.3, which depends on
Congrats! You have successfully created a terraspace project.
Check out the created files. Adjust to the examples and then deploy with:

    cd infra
    terraspace up demo -y   # to deploy
    terraspace down demo -y # to destroy

More info:
1 Like

The same on alpine
I faced it going through aws tutorial
An error occurred while installing racc (1.6.0), and Bundler cannot continue.

In Gemfile:
  terraspace was resolved to 0.6.20, which depends on
    terraspace_plugin_azurerm was resolved to 0.3.2, which depends on
      azure-storage-blob was resolved to 2.0.3, which depends on
        azure-storage-common was resolved to 2.0.4, which depends on
          nokogiri was resolved to 1.12.5, which depends on

Released terraspace v1

It should fix the Docker image issue. Here’s confirmation:

$ docker run -ti boltops/terraspace
root@d91540a984bc:~# cat /etc/os-release 
VERSION="20.04.3 LTS (Focal Fossa)"
PRETTY_NAME="Ubuntu 20.04.3 LTS"
root@d91540a984bc:~# terraspace version

In terraspace 1.0.0, improved the terraspace wrapper generated by the standalone installers. Details here:

You won’t have to remember to type bundle exec.

In addition, added a friendly usage message with instructions on how to resolve if the error occurs. PR: The standalone installer’s new shim, as of terraspace 1.0.0 includes this smarter shim already.

Also, remove terraspace_plugins_* out of terraspace core. This should also mitigate gem dependency graph resolution issues.

Believe this should resolve the issues.

Also, as a part of this, updated all the standalone installers and Terraspace Docker images.

Docker images are now versioned properly. Example:


More docs:

Hi tung, thanks for this.

I tried to use the boltops/terraspace:1.0.0-ubuntu image.

On first try when I ran terraspace up new project infra

I got the following error:

Installing terraspace_plugin_aws 0.3.7                                                                           [105/205]
Installing terraspace 1.0.6 (was 1.1.7)            
Bundle complete! 3 Gemfile dependencies, 49 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Gem::ConflictError: Unable to activate aws-sdk-dynamodb-1.74.0, because aws-sdk-core-3.125.1 conflicts with aws-sdk-core (
~> 3, >= 3.127.0)                              
ERROR: Unable to require plugin terraspace_plugin_aws                                                                  
Are you sure you the plugin exists and you specified the right plugin option.
You specified --plugin aws                           

But when I tried a second time it ran smoothly without any error. Should I worry about the above error?

Naw. It’s fine. When you first generate a project, looks like that error can happen sometimes. The terraspace new is a little bit special in that it runs outside of a Terraspace project and then calls bundle install as part of the generator. Actually had to Gem.clear_paths in order to allow bundle install to work. Guessing that causes the error you’re seeing when bundle install is called within the same “process” with the same “memory”. That’s why the 2nd time you called it was “fixed”.

Wondering if perhaps should just remove the bundle install outside and include it as a step in the printed instructions. That might avoid these additional edge cases. Hopefully that helps explain it.

Anyway, when in doubt about Gemfile dependencies. Do this:

cd project 

It helps to think about your Terraspace project as a full app with app dependencies, like a rails, nodejs, djanjgo app. The Gemfile contains all of those dependencies. It’s usually only 2 gems in Gemfile, IE: terraspace and terraspace_plugin_aws or whatever cloud provider you’re using. But it’s still the app’s dependencies.

Running bundle is the same as bundle install. It’s installs the gem dependencies and actually pins their versions by creating a Gemfile.lock. This helps if someone else on the team clones down the project, all they have to do is run bundle and it’ll ensure that they’re running all the same pinned versions as you.

You only have to run bundle when the Gemfile or Gemfile.lock has changed. Or the system gems itself has changed so that some gems are not available that Gemfile.lock needs. Think might add some notes to the doc explaining that the Terraspace project can be thought as an app you deploy with dependencies to help explain. Unsure.

Thanks for the detailed explanation.

Yes, after the error, I was able to do all the normal workflow; like creating a stack and running terraspace plan, up, etc. I just wanted to make sure.

I am new to Ruby and couldn’t parse the errors myself. As you said mentioning

cd project

in the docs will help people not familiar with Ruby.

So currently all problems are resolved and I can work with the latest Ubuntu image.

Just to get clarity, the error in initial post has this:

You have to install development tools first.

So I created a new image with the step:

RUN apt-get install -y ubuntu-dev-tools

That solved the issue for me but the image became too large 1.1 GB and it took a lot of time to get built. But the latest images doesn’t have this error! and the images are small, I would like to know how you solved it. Sorry I’m bothering you too much :smile:

The Docker image size is probably still small because the Docker images uses the Terraspace standalone installer. So only the artifacts like Ruby binaries and terraspace gems are installed. IE: The development packages like compilers are not installed, so less disk space is used. There are pros and cons with this.

RE: bundle docs

Yup. Will add to the docs in time. Will also consider PRs for doc improvements. Of course. No sweat either way :+1: