# Error Occurred while installing 'bundle install' and 'gem install json

**URL:** <https://www.ruby-forum.com/t/error-occurred-while-installing-bundle-install-and-gem-install-json/262596>\
**Category:** Rails\
**Created:** [March 15, 2022, 1:36pm UTC](https://www.ruby-forum.com/t/error-occurred-while-installing-bundle-install-and-gem-install-json/262596 "2022-03-15T13:36:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sony](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cab0a1/32.png) [@sony](https://www.ruby-forum.com/u/sony)\
**Post date:** [March 15, 2022, 1:36pm UTC](https://www.ruby-forum.com/t/error-occurred-while-installing-bundle-install-and-gem-install-json/262596/1 "2022-03-15T13:36:07Z")

</div>

Im trying to setup ruby on local and I am running into some issues.

**1. When i run ‘bundle install’ , the following error occur**

Installing json 2.6.1 with native extensions  
**Gem::Ext::BuildError: ERROR: Failed to build gem native extension.**

fatal error: ‘ruby/config.h’ file not found  
#include “ruby/config.h”  
^ ~~~~~~~~~~~~~~  
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10:  
note: did not find header ‘config.h’ in framework ‘ruby’ (loaded from  
‘/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks’)  
1 error generated.  
make: \*\*\* [generator.o] Error 1  
make failed, exit code 2  
Gem files will remain installed in /Users/\*\*/.gem/gems/json-2.6.1 for inspection.  
Results logged to  
/Users/\*\*\*\*/.gem/extensions/universal-darwin-21/2.6.0/json-2.6.1/gem\_make.out

**An error occurred while installing json (2.6.1), and Bundler cannot continue.**  
In Gemfile:  
coveralls was resolved to 0.8.23, which depends on  
simplecov was resolved to 0.16.1, which depends on  
json

**==============**  
**2. Then i executed ‘gem install json’, the following error occurred**

Building native extensions. This could take a while…  
ERROR: Error installing json:  
ERROR: Failed to build gem native extension.

1 error generated.  
make: \*\*\* [generator.o] Error 1  
make failed, exit code 2  
Gem files will remain installed in /Users/\*\*/.gem/gems/json-2.6.1 for inspection.  
Results logged to /Users/\*\*\*\*/.gem/extensions/universal-darwin-21/2.6.0/json-2.6.1/gem\_make.out

- I am using macOS 12.2.1
- ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.x86\_64-darwin21]
- bundler version 2.3.9
- gem version 3.3.9

Any help would be great.

Thanks

---

<div class="post-metadata">

**Author:** ![SouravGoswami](https://www.ruby-forum.com/user_avatar/www.ruby-forum.com/souravgoswami/32/2543_2.png) [@SouravGoswami](https://www.ruby-forum.com/u/SouravGoswami)\
**Post date:** [March 15, 2022, 3:19pm UTC](https://www.ruby-forum.com/t/error-occurred-while-installing-bundle-install-and-gem-install-json/262596/2 "2022-03-15T15:19:48Z")

</div>

This is a very common error. You get this whenever you’re using Linux distributions like Ubuntu, Fedora, and OpenSUSE. They don’t provide you ruby-devel package by default, but the gem you’re using contains native C extensions. Ruby.h provides the Ruby C API. And a lot of gem use that.

To solve the issue, you need to install the ruby-dev package on Ubuntu, or ruby-devel package on Fedora / OpenSUSE. You also need a compiler to compile the code that’s using ruby.h.

Ubuntu:

```auto
# apt install gcc build-essential ruby ruby-dev build-essential

```

Fedora:

```auto
# yum install gcc ruby-devel ruby make

```

OpenSUSE:

```auto
# zypper install gcc ruby ruby-devel make

```

All the # means as a root user. In most cases, `sudo` or login as `su` works.

You can easily remove the packages once the gems are build. But you may keep them for future use, for instance, during updating those gems.

---

<div class="post-metadata">

**Author:** ![Ayushman](https://www.ruby-forum.com/user_avatar/www.ruby-forum.com/ayushman/32/3087_2.png) [@Ayushman](https://www.ruby-forum.com/u/Ayushman)\
**Post date:** [November 11, 2022, 8:54am UTC](https://www.ruby-forum.com/t/error-occurred-while-installing-bundle-install-and-gem-install-json/262596/3 "2022-11-11T08:54:38Z")

</div>

Such issues are common in coding and computing languages. To solve this, you will be required to download or install the ruby-dev package on Ubuntu or the ruby-devel package.

---

<div class="post-metadata">

**Author:** ![Mrmoon34](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@Mrmoon34](https://www.ruby-forum.com/u/Mrmoon34)\
**Post date:** [November 11, 2024, 8:37am UTC](https://www.ruby-forum.com/t/error-occurred-while-installing-bundle-install-and-gem-install-json/262596/4 "2024-11-11T08:37:35Z")

</div>

I running through similar error on macosx, please provide solution for the same.
