how to run bundle install on ubuntu 16.04 LTS - json

I have a problems to run the bundle install on my PC. The return is:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /tmp/bundler20170309-28068-jc2jotsqlite3-1.3.13/gems/sqlite3-1.3.13/ext/sqlite3
/usr/bin/ruby2.3 -r ./siteconf20170309-28068-19m0tjz.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/bundler20170309-28068-jc2jotsqlite3-1.3.13/gems/sqlite3-1.3.13 for inspection.
Results logged to /tmp/bundler20170309-28068-jc2jotsqlite3-1.3.13/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/gem_make.out
Using turbolinks-source 5.0.0
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.
I try run gem install json -v '1.8.6' but it did not work.
Can someone help me?
Sorry my english.

Related

Bundle Install Json Error

My ruby environment is pretty much setup. I can retrieve my Gherkins syntax via command line and run simple ruby web tests. But I need some other gems to complete the environment. All I need to do is get bundle install working, but can't figure out why it's not installing. I've updated my gems as well. I'm using Ruby 2.2.3 on Windows 10. Below is my output after trying to run.
C:\GitHubFiles\MyAccountWeb-Tests>bundle install
Fetching gem metadata from http://rubygems.org/............
Resolving dependencies...
Using public_suffix 3.0.2
Using addressable 2.5.2
Using awesome_print 1.8.0
Installing json 2.1.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20180817-13500-1p562oy.rb extconf.rb creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
make failed, uncaught signal 11
Gem files will remain installed in
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/json-2.1.0 for inspection.
Results logged to
C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/json-2.1.0/gem_make.out
An error occurred while installing json (2.1.0), and Bundler cannot
continue.
Make sure that `gem install json -v '2.1.0' --source 'http://rubygems.org/'`
succeeds before bundling.
In Gemfile:
appium_lib was resolved to 9.7.1, which depends on
json
My source is already set to 'http://rubygems.org/'. I ran 'gem sources -r https://rubygems.org -a http://rubygems.org' to confirm this. My output after trying to run 'gem install json -v '2.1.0' is below.
C:\GitHubFiles\MyAccountWeb-Tests>gem install json -v '2.1.0'
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/json-2.1.0/ext/json/ext/generator
C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20180817-15312-13stnps.rb extconf.rb
creating Makefile
current directory: C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/json-2.1.0/ext/json/ext/generator
make "DESTDIR=" clean
current directory: C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/json-2.1.0/ext/json/ext/generator
make "DESTDIR="
make failed, uncaught signal 11
Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/json-2.1.0 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/json-2.1.0/gem_make.out
gem_make text file
current directory: C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/json-2.1.0/ext/json/ext/generator
C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20180817-10044-ypvx4a.rb extconf.rb
creating Makefile
current directory: C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/json-2.1.0/ext/json/ext/generator
make "DESTDIR=" clean
current directory: C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/json-2.1.0/ext/json/ext/generator
make "DESTDIR="
make failed, uncaught signal 11
According to this link, I should try rake install. https://www.rubydoc.info/gems/json/2.1.0. But it just says rake aborted. No rake file found.
I also tried 'gem install bundler -v '= 1.5.1'' followed by 'bundle package', which created the same json error.
I've tried bundle update and bundle update json.
I read that there was a problem with json version 1.8.1 and ruby 2.2.3, so install json 1.8.3 version, so I tried gem install json -v1.8.3. Same json error.
I tried deleting my gemfile and running bundle update again, which replaced the gemfile and created the bundle install error again :(
I am stuck!

Rails - mysql2 installation error

I have recently installed rvm to use rails5 along with rails3.x version in my current system. When i tried to create new rails5 application, i have got the below error
Could not find proper version of railties (3.2.13) in any of the sources
Run `bundle install` to install missing gems.
And when i try to do bundle install, i got stuck with this
gem install mysql2 -v '0.3.11'
Building native extensions. This could take a while...
/home/himanth/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/ext/builder.rb:73: warning: Insecure world writable dir /home/himanth/.rvm/gems in PATH, mode 040777
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/home/himanth/.rvm/rubies/ruby-2.3.1/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling mysql2_ext.c
In file included from ./client.h:11:0,
from ./mysql2_ext.h:39,
from mysql2_ext.c:1:
/home/himanth/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete [-Wcpp]
In file included from ./mysql2_ext.h:39:0,
from mysql2_ext.c:1:
./client.h: In function 'rb_thread_blocking_region':
./client.h:23:3: error: 'TRAP_BEG' undeclared (first use in this function)
./client.h:23:3: note: each undeclared identifier is reported only once for each function it appears in
./client.h:25:3: error: 'TRAP_END' undeclared (first use in this function)
mysql2_ext.c: At top level:
./client.h:16:1: warning: 'rb_thread_blocking_region' defined but not used [-Wunused-function]
make: *** [mysql2_ext.o] Error 1
make failed, exit code 2
Gem files will remain installed in /home/himanth/.rvm/gems/ruby-2.3.1#rails5/gems/mysql2-0.3.11 for inspection.
Results logged to /home/himanth/.rvm/gems/ruby-2.3.1#rails5/extensions/x86_64-linux/2.3.0/mysql2-0.3.11/gem_make.out
An error occurred while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.
Got stuck with this for quite some time, any help would be much appreciated.
From Terminal try following:
For Ubuntu:
sudo apt-get install mysql-client libmysqlclient-dev
sudo gem install mysql2
For Mac:
brew install mysql
sudo gem install mysql2
try the below:
gem install rails
After that install mysql server
sudo apt-get install mysql-client libmysqlclient-dev
then bundle install

Failed to install mysql2 gem on Ubuntu 14

I'm running Ubuntu 14 and when I try to run rails server but I get this error:
Could not find gem 'mysql2 (>= 0) ruby' in the gems available on this machine.
Run bundle install to install missing gems.
So I run the bundle install and then I get the following error.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.1 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.1.0/gems/mysql2-0.3.16 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/mysql2-0.3.16/gem_make.out
An error occurred while installing mysql2 (0.3.16), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.16'` succeeds before bundling.
So I run gem install mysql2 -v '0.3.16' and it installs successfully however when I run bundle install again it gives me the same error:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.1 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.1.0/gems/mysql2-0.3.16 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/mysql2-0.3.16/gem_make.out
An error occurred while installing mysql2 (0.3.16), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.16'` succeeds before bundling.
Start again from scratch and this time you should install RVM as it is really good at handling all this stuff for you.
http://rvm.io/rvm/install
Make sure you get all the dependencies first, this code will check to see what you have and don't have:
for name in {bash,awk,sed,grep,ls,cp,tar,curl,gunzip,bunzip2,git,svn} ; do which $name ; done
Its also worth looking at the prerequisites page: http://rvm.io/rvm/prerequisites
You can run the below code to install rvm with Ruby 2.1.1 and Rails:
\curl -sSL https://get.rvm.io | bash -s stable --rails
Then To start using RVM:
/bin/bash --login
Its definitely worth using RVM it will make your life much easier when managing your ruby versions, gems etc, just make sure you read through the webpage so that you know how to use it.

Rails 3.2.3 MySQL 5.5.1 Mysql2 gem install fails with ld incompatibilities

I have a clean build system as follows
Ubuntu 11.04
Rvm 1.13.5
Ruby 1.9.3p194
Rails 3.2.3
Gem 1.8.24
MySql 5.5.24-1 (installed in /usr/local)
I am trying to install the mysql2 gem (0.3.11) and getting the following problem:
pal#smurf01:~$ sudo gem install mysql2
[sudo] password for pal:
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
compiling client.c
client.c: In function 'rb_raise_mysql2_error':
client.c:98:3: warning: ISO C90 forbids mixed declarations and code
client.c: In function 'rb_mysql_client_socket':
client.c:590:3: warning: ISO C90 forbids mixed declarations and code
compiling mysql2_ext.c
compiling result.c
linking shared-object mysql2/mysql2.so
/usr/bin/ld: skipping incompatible /usr/local/mysql/lib/libmysqlclient_r.so when searching for -lmysqlclient_r
/usr/bin/ld: skipping incompatible /usr/local/mysql/lib/libmysqlclient_r.a when searching for -lmysqlclient_r
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
make: *** [mysql2.so] Error 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
pal#smurf01:~$
First question: Has anyone got Rails mysql2 running with MySql 5.5.1 on Ubuntu? I have it running on another system with 5.1. The gem description is vague on supported MySql versions.
Second question: Has anyone encountered this problem? I± have battled various library issues with the mysql2 gem over the passed year or so but this seems to be different.
Any assistance is gratefully recieved.
BTW: Reverting back to MySql 5.1 is a valid solution!
Regards
Peter
Or just apt-get install libmysqlclient-dev and then gem install mysql2
So the problem appears to have been a missing library and some links. Doing the following solved the issue.
Get the new and install the libmysqlclient-dev deb package kindly provided by Nathan Rennie Waldock
wget http://ppa.launchpad.net/nathan-renniewaldock/ppa/ubuntu/pool/main/m/mysql-5.5/libmysqlclient-dev_5.5.24-1~ppa1~natty_amd64.deb./;l
dpkg -i libmysqlclient-dev_5.5.24-1~ppa1~natty_amd64.deb
Then create some links that mysql2 needs as it can't seem to follow the mysql path
cd /usr/lib/
ln -s /usr/local/mysql-5.5.24-linux2.6-x86_64/lib/libmysqlclient_r.a .
ln -s /usr/local/mysql-5.5.24-linux2.6-x86_64/lib/libmysqlclient_r.so .
ln -s /usr/local/mysql-5.5.24-linux2.6-x86_64/lib/libmysqlclient_r.so.18 .
ln -s /usr/local/mysql-5.5.24-linux2.6-x86_64/lib/libmysqlclient_r.so.18.0.0 .
Now happily install the mysql2 gem
sudo gem install mysql2
Fetching: mysql2-0.3.11.gem (100%)
Building native extensions. This could take a while...
Successfully installed mysql2-0.3.11
1 gem installed
Installing ri documentation for mysq2l-0.3.11...
Installing RDoc documentation for mysql2-0.3.11...
Had the same issue in Ubuntu 12.04 also using the ppa mentioned in the accepted answer.
But also there was no libmysqlclient file on my system with _r in the name.
Googling around I found out that package builders have started to drop the _r suffix from the files, so that might have happened between 11.10 and 12.04.
Also the paths were a bit different to the once mentioned so these are the symlinks that I had to create:
ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.a ./libmysqlclient_r.a
ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so ./libmysqlclient_r.so
ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18 ./libmysqlclient_r.so.18
ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18.0.0 ./libmysqlclient_r.so.18.0.0
I had this problem as well...
I did dpkg -r mysql-devel as when I was trying to do apt-get install libmysqlclient-dev I got an error saying:
Unpacking libmysqlclient-dev (from .../libmysqlclient-dev_5.5.24-0ubuntu0.12.04.1_i386.deb) ... dpkg:
error processing
/var/cache/apt/archives/libmysqlclient-dev_5.5.24-0ubuntu0.12.04.1_i386.deb
(--unpack): trying to overwrite '/usr/bin/mysql_config', which is
also in package mysql-devel 5.5.28-2
After doing this, gem install mysql2 worked! yay :)

Problem with rake db:migrate

When I try rake db:migrate, I get the following error:
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
no such file to load -- mysql
And when I try to "gem install mysql"
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
Can't find header files for ruby.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
I checked the rubygems folder and mysql gem has been installed. Any ideas? Cheers
This should sort it out on Ubuntu:
sudo aptitude install libmysqlclient-dev build-essential
Then install the gem again. You may need to delete the /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 folder if it craps out.
I hope that helps.
The gem hasn't actually been installed. You are missing either the ruby development files, mysql developer files, or linux build essentials. Since you are asking, I'll assume you are on a linux distribution with a package manager; install the corresponding packages.
As Sleepycat suggested, most probably you need the dev libraries for MySQL.
On Fedora / CentOS this should solve your problem:
yum install mysql-devel
gem install mysql