2

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.

Himanth Kumar
  • 316
  • 2
  • 13
  • try to put this in your gemfile and do bundle install, gem 'mysql2', '~> 0.3.18' – Navin Sep 20 '16 at 13:12
  • I did not even complete creating project, when i try creating new project, i get this error.. Could not find proper version of railties (3.2.13) in any of the sources Run `bundle install` to install missing gems. Which is confusing.. – Himanth Kumar Sep 20 '16 at 13:25
  • RVM is for ruby versions, not rails versions. If you've installed both rails 3 and rails 5 gems at system level, when you run rails new you might need to tell your system which rails version to use (http://stackoverflow.com/a/452458/385532) – Matt Sep 20 '16 at 13:26
  • Yes Matt, i use two different ruby versions.. 1.9.3 and 2.3.1 respectively.. When i switch to rvm ruby 2.3.1, create new gemset and try create new app, i am getting this error – Himanth Kumar Sep 20 '16 at 13:27
  • Once I had the same issue, http://stackoverflow.com/questions/27832120/error-error-installing-mysql2-error-failed-to-build-gem-native-extension worked for me. – Tushar H Sep 20 '16 at 13:35
  • I think u haven't install rails for the ruby 2.3.1 – Chakreshwar Sharma Sep 20 '16 at 13:36
  • @Tushar: You find dufficulty in installing mysql2 & as per this question, the error seems that rails is not installed for the specific version – Chakreshwar Sharma Sep 20 '16 at 13:37
  • @HimanthKumar: Try my below solution written below & let me know if you find the problem again – Chakreshwar Sharma Sep 20 '16 at 13:39
  • No luck @ChakreshwarSharma I get this error even when trying to create a new rails app... Could not find proper version of railties (3.2.13) in any of the sources Run `bundle install` to install missing gems. – Himanth Kumar Sep 20 '16 at 13:46
  • Switch to ruby 231 and run `gem list` and post the outcome please – Matt Sep 20 '16 at 13:54
  • mysql2 (0.4.4) Will you be interested to see any other specific gem list? – Himanth Kumar Sep 20 '16 at 13:57
  • I could create new app only with my first ruby 1.9.3 version, not with any other versions.. – Himanth Kumar Sep 20 '16 at 14:38
  • So running `gem list` doesn't actually list rails? That could be your problem... post the whole list. – Matt Sep 20 '16 at 14:49
  • @HimanthKumar: run rails -v & paste the output – Chakreshwar Sharma Sep 21 '16 at 07:54

2 Answers2

0

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
Tushar H
  • 755
  • 11
  • 29
0

try the below:

gem install rails

After that install mysql server

sudo apt-get install mysql-client libmysqlclient-dev

then bundle install

Chakreshwar Sharma
  • 2,571
  • 1
  • 11
  • 35