bundle cannot build gem native extension while gem can - json - ruby-on-rails

I know, yet another question of the kind, but nothing helped so far.
When I run bundle install on the production server I get the following error:
...
Installing json (1.6.3) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
Gem files will remain installed in /home/onblimp/onblimp/releases/20111213131738/RAILS_ENV=production/ruby/1.9.1/gems/json-1.6.3 for inspection.
Results logged to /home/onblimp/onblimp/releases/20111213131738/RAILS_ENV=production/ruby/1.9.1/gems/json-1.6.3/ext/json/ext/parser/gem_make.out
An error occured while installing json (1.6.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.6.3'` succeeds before bundling.
When I run gem install json -v '1.6.3' it installs without error. I'm running both commands as a root. In development it works well. A few days ago it also worked well.
Any help is appreciated.

I've managed to solve this issue by simply restarting the server. It would be great to know the cause, but I guess that's too much to ask.

hey i got the same error .I installed xcode and restart my mac.Then i made new project in rails and got into this
**Errno::EPERM: Operation not permitted
An error occured while installing json (1.6.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.6.3'` succeeds before bundling**
i just did sudo gem install json -v '1.6.3' it worked fine in my case.

Related

Bundle install errors and cannot continue, even after installing missing gems

I am working on multiple Ruby on Rails applications and running...
MacOS 10.15.7,
Ruby 2.6.5,
Rails 5.2.3,
In a project app directory I am trying to run a bundle install and get the following error:
An error occurred while installing jaro_winkler (1.5.3), and Bundler cannot continue.
Make sure that `gem install jaro_winkler -v '1.5.3' --source
'https://.../api/gems/rubygems/'` succeeds before bundling.
I proceed to install the gem from the specified source and get confirmation of install
Building native extensions. This could take a while...
Successfully installed jaro_winkler-1.5.3
Parsing documentation for jaro_winkler-1.5.3
Done installing documentation for jaro_winkler after 0 seconds
1 gem installed
after running bundle install again, I will get the original error
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/private/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3/ext/jaro_winkler
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r
./siteconf20210406-62421-10txxc5.rb extconf.rb
creating Makefile
current directory:
/private/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3/ext/jaro_winkler
make "DESTDIR=" clean
current directory:
/private/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3/ext/jaro_winkler
make "DESTDIR="
make: *** No rule to make target
`/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19/ruby/config.h',
needed by `adj_matrix.o'. Stop.
make failed, exit code 2
Gem files will remain installed in
/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3
for inspection.
Results logged to
/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/extensions/universal-darwin-19/2.6.0/jaro_winkler-1.5.3/gem_make.out
An error occurred while installing jaro_winkler (1.5.3), and Bundler cannot continue.
Make sure that `gem install jaro_winkler -v '1.5.3' --source
'https://.../api/gems/rubygems/'` succeeds before bundling.
The error message above doesn't give me any clear indication of what is happening. Additionally there is no such directory in the location where the message says "results logged to."
This seems to be happening in multiple application directories - but with different affected gems in each directory. They are all similar in that the error reads "make sure gem succeeds before bundling", then the gem install will succeed, and then the following bundle install will fail with the same original message.
Earlier today I did a clean Ruby 2.6.5 install and updated the Xcode CLI via xcode-select --install
If I run gem which jaro_winkler I get
/Users/{username}/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/jaro_winkler-1.5.3/lib/jaro_winkler.rb
Does anyone have any information on what could be causing this? I cannot do any bundle install without this happening. Please let me know if any more information is desired.
Thank you!
You mentioned that you are using ruby 2.6.5, but the gem is attempting to be installed in 2.6.0. Check that your Gemfile has the correct Ruby version in it.
When you ran gem which, it looks you are using rbenv. Make sure that you are using the correct Ruby version in there, too. Those rubies get installed in a different directory than xcode's. Sometimes there's a .rbenv file in the dir that will set the version as well.
Just some ideas. Hopefully something sticks.
Ended up being an issue with gem install location - export PATH="/usr/local/bin:$PATH" was previously added to my .bash_profile and this was effecting where gems were installed.
Somewhere in the error message /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby is mentioned - this is the "system default" Mac version of Ruby and is not the Ruby version I was intending to use with .rbenv ( 2.6.5 ) and gem installs.
Removing the export mentioned above help resolve the issue.
edit- wording

Ruby - "bundle install" json gem error

I am working on Windows 10. I successfully installed Ruby, MSYS2 and DevKit, but after trying to run the following command:
bundle install
it throws me an error
An error occurred while installing json (1.8.1), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.1'` succeeds before bundling.
I tried the solution with
gem install json -v '1.8.1'
but it still doesn't work for me.
Does anybody knows how i can fix the error?

An error occurred while installing json (1.8.6), and Bundler cannot continue

I tried to run the bundle install command and I got the following errors. After reading some stackoverflow posts, I also ran bundle update.
I am still getting the issue of json ~ 1.8.6 gem (I guess).
An error occurred while installing json (1.8.6), and Bundler cannot
continue. Make sure that gem install json -v '1.8.6' succeeds before
bundling.
Here the issue is not getting installation done properly.
Older versions of json gem have some incompatibilities with newer ruby. Try to update json gem bundle update json
This can be solved by doing the following
1. Installing the ruby development environment by running the following command(for Linux machines).
sudo apt-get install ruby
ruby -e 'puts RUBY_VERSION[/\d+\.\d+/]' -dev
Read this post for more details.
2. Now install the json -v '1.8.6' gem by running the following command.
sudo gem install json -v '1.8.6'
This should solve the issue. Now try running bundle update and bundle install and it should work fine.
Thanks #TomLord and #Haider Ali for your inputs.

Gem::Ext::BuildError: ERROR: Failed to build gem native extension for rails version 4.2.6

I have created new rails app and try to run bundle install it shows this error,
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/json-1.8.6/ext/json/ext/generator/usr/bin/ruby2.3 -r ./siteconf20170704-11395-12tpg5u.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 /var/lib/gems/2.3.0/gems/json-1.8.6 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/json-1.8.6/gem_make.out
An error occurred while installing json (1.8.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.6'` succeeds before bundling
Kindly send me some suggestions,Thanks in Advance.
If you have a Mac or Linux machine try the following command:
sudo apt-get install ruby-dev
If that fails, what is your output for:
gem install json -v '1.8.6'
(please copy and paste all the output).
Similar issue
I'm not sure what will fix it for Mac, but people had positive experiences with brew install ruby.
If anyone facing this error with Mac OS Big Sur, please update the ruby version to atleast 2.7. I am using rvm to resolve this issue.
First checked the ruby version and rvm list
if rvm not install then install rvm

RubyOnRails- How to bundle?

I am trying to install all dependencies via following command:
bundle install
It gave me following error:
An error occurred while installing libv8 <3.16.14.13>, and bundle cannot continue.
Make sure that 'gem install libv8 -v '3.16.14.13' ' succeeds before bundling.
Then from this link:
Error installing libv8: ERROR: Failed to build gem native extension
I found this solution:
gem install libv8 -v '3.16.14.13' -- --with-system-v8
It then installed the libv8
Then again I ran the command:
bundle install
Now its giving me following error:
An error occurred while installing therubyracer <0.12.2>, and bundler cannot continue.
Make sure that 'gem install therubyracer -v '0.12.2' ' succeeds before bundling.
I tried deleting therubyracer from gem file and then run the command but i am getting the same error.
Please guide me.
Thanx
I see that you are using Windows 7 , then prepare yourself:
Unfortunately, there's no know way of installing that gem on Windows:
Linked question: therubyracer not installing on Windows
This is one of many things that made me change to Linux.
EDIT
There is a workaround but its from 4 years ago so , I hope this will work:
https://github.com/eakmotion/therubyracer_for_windows
EDIT 2 - About middleman
Did you install the DevKit for RubyInstaller?.
Here you have the documentation of the gem with the installation steps:
https://github.com/middleman/middleman
EDIT 3
Check this one. There are others with the same issue (of course) and they managed to "solved" it using it:
https://github.com/jawwadzafar/middleman-boilerplate

Resources