Data Structure Exercises - bundle install issue

I’m getting the following error when trying to run bundle install for the Data Structures Exercises:

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

current directory: /tmp/bundler20180730-4383-196g8i9byebug-9.0.6/gems/byebug-9.0.6/ext/byebug

/usr/bin/ruby2.5 -r ./siteconf20180730-4383-prjdl8.rb extconf.rb
mkmf.rb can’t find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20180730-4383-196g8i9byebug-9.0.6/gems/byebug-9.0.6
for inspection.
Results logged to
/tmp/bundler20180730-4383-196g8i9byebug-9.0.6/extensions/x86_64-linux/2.5.0/byebug-9.0.6/gem_make.out

An error occurred while installing byebug (9.0.6), and Bundler cannot continue.
Make sure that gem install byebug -v '9.0.6' --source 'https://rubygems.org/' succeeds before
bundling.

In Gemfile:
byebug

What should I do?

Hi DFLO,

Is it just byebug that is in your Gemfile? You should have this:

source “https://rubygems.org

gem “byebug”
gem “rspec”, “~> 3.2.0”

You can copy this code to your Gemfile and then run bundle install again. Let me know if this fixes the problem.

Michael

Hi Michael,

No, my Gemfile is exactly as you listed.

Here’s the full Terminal output:

dflood@dflood-Inspiron-5558:~/appacademy-online-data-structure-exercises-535340b22373$ bundle install
Fetching gem metadata from https://rubygems.org/
Using bundler 1.16.3
Fetching byebug 9.0.6

Your user account isn’t allowed to install to the system RubyGems.
You can cancel this installation and run:

  bundle install --path vendor/bundle

to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to RubyGems using sudo.

Password:
Installing byebug 9.0.6 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /tmp/bundler20180730-4383-196g8i9byebug-9.0.6/gems/byebug-9.0.6/ext/byebug

/usr/bin/ruby2.5 -r ./siteconf20180730-4383-prjdl8.rb extconf.rb
mkmf.rb can’t find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20180730-4383-196g8i9byebug-9.0.6/gems/byebug-9.0.6
for inspection.
Results logged to
/tmp/bundler20180730-4383-196g8i9byebug-9.0.6/extensions/x86_64-linux/2.5.0/byebug-9.0.6/gem_make.out

An error occurred while installing byebug (9.0.6), and Bundler cannot continue.
Make sure that gem install byebug -v '9.0.6' --source 'https://rubygems.org/' succeeds before
bundling.

In Gemfile:
byebug
dflood@dflood-Inspiron-5558:~/appacademy-online-data-structure-exercises-535340b22373$

I don’t know if this is the problem, but make you you’ve installed the Xcode command line tools with:

xcode-select --install

You can follow this blog and see if it fixes the problem: http://jessehouse.com/blog/2015/02/03/rbenv-and-your-user-account-isnt-allowed-to-install-to-the-system-rubygems/.

I tried running xcode --install but got the error: “xcode-select: command not found”

I’m working with Ubuntu if that makes a difference.

Yes. There is no xcode or homebrew for Ubuntu and linux system.

I followed through the blog and when I ran rbenv local I got “rbenv: no local version configured for this directory”

Sorry about that. That was for a OS system, but since you are working with ubuntu; it will be a bit different. Just a quick question did you install ruby using rbenv or rvm?

I installed it using rbenv.

Check out this stackoverflow thread and see if their solution helps. https://stackoverflow.com/questions/35112370/rbenv-bundle-install-tries-to-install-gems-into-wrong-path

I will keep looking for other solutions if that one does not work.

Unfortunately their solution did’t help. I’m still getting the same error.

I am a bit out of ideas besides a reinstallation of rbenv.
Follow my response to another student in this thread for a reinstallation guide: Trouble downloading Ruby version.

You need the ruby development headers.

Run this:

sudo apt-get install ruby-all-dev

Edit: Turns out this shouldn’t be necessary if rbenv is working properly. Post the output of which ruby to see if it’s using the system ruby or rbenv’s ruby

Hi Jeremiah,

Your suggestion worked, but based on your edit I’m guessing rbenv is not working and/or configured properly. My output for which ruby was /usr/bin/ruby

Saw you fixed your particular issue, but I wanted to pop in and add my two cents as an Ubuntu user- You’ll get used to troubleshooting your updates and packages! (especially which key words to search for)

Check out these two links for more information on how to install rbenv and for more details about it’s uses:


Yeah, rbenv isn’t working. It’s just using the system’s ruby. It’s definitely beneficial to get rbenv working, but the installation is harder on Ubuntu than on mac.

Make sure git is installed
sudo apt-get install git

To install rbenv follow the installation instructions under “Basic GitHub Checkout”

Do the optional step 6, install ruby-build. Follow the link given in step 6 for instructions on how to do that.

Now you should be able to run these commands from the Alpha Course:

# install Ruby version 2.3.1
rbenv install 2.3.1

# set version 2.3.1 to be our global default
rbenv global 2.3.1

Once that’s done ruby -v should output 2.3.1 and which ruby should output some path with rbenv in it.