mysql2 Gem::Ext::BuildError: ERROR: Failed to build gem native extension - ruby-on-rails-3

When I download the rails application from github
https://github.com/ari/jobsworth
An then give bundle install it throws error:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
An error occurred while installing mysql2 (0.4.4), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.4.4'` succeeds before bundling.
After I give the sudo gem install mysql2 -v '0.4.4' and it displays like:
Fetching: mysql2-0.4.4.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.4.0/gems/mysql2-0.4.4/ext/mysql2
/usr/bin/ruby2.4 -r ./siteconf20180212-10708-v1q8lj.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.4.0/gems/mysql2-0.4.4 for inspection.
Results logged to /var/lib/gems/2.4.0/extensions/x86_64-linux/2.4.0/mysql2-0.4.4/gem_make.out
After run bundle install it throws same error.

Running these commands worked for me.
brew install openssl
bundle config --global build.mysql2 --with-opt-dir="$(brew --prefix openssl)"
bundle
You can refer to this link for further help https://github.com/brianmario/mysql2/issues/1005

Related

react-native init 'failed to build gem native extension'

When I run npx react-native projectname, the project is only created partially.
Now when I run bundle install I get:
1. Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
2. An error occurred while installing ffi (1.15.5), and Bundler cannot continue. Make sure that "gem install ffi -v '1.15.5' --source 'https://rubygems.org/'" succeeds before bundling.
Yes, I have installed the ffi 1.15.5 (below screenshot) but it is still saying I dont have it
Ruby version: ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [arm64-darwin21]
pod --version: 1.11.3
I am impressed how difficult it is to start a project. Someone please help

cocoa pods error failed to build gem native extension on Mac

ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.18/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20200728-45926-1h0nq8i.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/includ.e/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.18 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.9.18/gem_make.out
I'm just trying to install it and it doesn't work.
PS: I also already have cocoa pods. I am simply following the instructions on react native setting up your environment
The below steps would fix that issue:
Ensure ruby is installed and up to date: ruby -v
Update gem's sudo gem update --system
xcode-select --install
sudo gem install -n /usr/local/bin cocoapods
Solved it by updating the repo
sudo gem repo update

error occurred while installing escape_utils (1.2.1)

When running the rails server i am getting "An error occurred while installing escape_utils (1.2.1), and Bundler cannot continue. Make sure that gem install escape_utils -v '1.2.1' succeeds before bundling". But after that when i run bundle install, i have received the following error " error occurred while installing escape_utils (1.2.1), and Bundler cannot continue. Make sure that gem install escape_utils -v '1.2.1' succeeds before bundling".
Could anyone guide me how to fix this?
You need to run gem install escape_utils -v '1.2.1' to install the gem without using bundler. It will probably fail and the trace that it prints will tell you what's happening and where to find the error log file for more info on what's missing.
That gem has native extensions that it needs to compile, if it gives you an error while compiling them, you probably have a missing system dependency.

I am getting this error while installing blacklight project in ruby on rails for the bundle install in ubuntu 16.04

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /tmp/bundler20170529-7305-1ybn2iijson-1.8.6/gems/json-1.8.6/ext/json/ext/generator
/usr/bin/ruby2.3 -r ./siteconf20170529-7305-1qu2mp6.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/bundler20170529-7305-1ybn2iijson-1.8.6/gems/json-1.8.6 for inspection.
Results logged to /tmp/bundler20170529-7305-1ybn2iijson-1.8.6/extensions/x86_64-linux/2.3.0/json-1.8.6/gem_make.out
Thanks for asking! Do you have the ruby-dev package installed? You can get it with:
sudo apt-get install ruby-dev

Getting gem exception while deployin code on server

Hi i am getting a gem exception error:
Gem::Exception: Cannot load gem at [/usr/lib/ruby/gems/1.8/cache/Ascii85-1.0.1.gem] in /home/profweb/rails-apps/profitnext/releases/20120628123949
** [out :: profitnext.com] An error occured while installing Ascii85 (1.0.1), and Bundler cannot continue.
** [out :: profitnext.com] Make sure that `gem install Ascii85 -v '1.0.1'` succeeds before bundling.
command finished in 607967ms
*** [deploy:update_code] rolling back
Although i have installed that gem in gem file and it shows in gem list on local host. Can somebody tell me why i am getting this error in "cap deploy" command.
Are you sure you have all dependencies installed on the remote host? Similar errors are produced if you're installing a gem and don't have required packages installed on your system
i got where the real problem is. I have added a line in my "deploy.rb" file and added the required gem in my gemfile and run the bundle install. Now i can easily deploy my code. Thanks for reply friends.