2016-09-20 138 views
2

我最近安装了rvm,在当前系统中使用rails5以及rails3.x版本。当我试图创造新的rails5应用程序,我已经得到了以下错误Rails - mysql2安装错误

Could not find proper version of railties (3.2.13) in any of the sources 
Run `bundle install` to install missing gems. 

,当我尝试做捆绑安装,我被困这个

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/[email protected]/gems/mysql2-0.3.11 for inspection. 
Results logged to /home/himanth/.rvm/gems/[email protected]/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. 

卡住了与此相当长的一段时间,任何帮助将不胜感激。

+0

尝试把这个在你的Gemfile做捆绑安装后, gem'mysql2','〜> 0.3.18' – Navin

+0

我甚至没有完成创建项目,当我尝试创建新的项目,我得到这个错误.. 在任何来源找不到适当版本的railties(3.2.13) 运行'bundle install'来安装缺失的gem。 这是令人困惑的.. –

+0

RVM是为ruby版本,而不是rails版本。如果您已在系统级别安装了rails 3和rails 5 gem,则在运行rails时,可能需要告诉系统要使用哪个rails版本(http://stackoverflow.com/a/452458/385532) – Matt

回答

0

从终端尝试以下操作:

对于Ubuntu的:

sudo apt-get install mysql-client libmysqlclient-dev 
sudo gem install mysql2 

对于Mac:

brew install mysql 
sudo gem install mysql2 
-1

你没有在你的新宝石

首先安装滑轨安装滑轨用命令gem install rails

然后运行bundle install

0

尝试以下:

gem install rails 

是安装mysql服务器

sudo apt-get install mysql-client libmysqlclient-dev 

然后bundle install