ERROR: Failed to build gem native extension.

Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb --with-mysql-dir=/usr/bin --with-mysql-lib=/usr/lib/mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

This error occur by the lack of “libmysql-ruby libmysqlclient-dev” library, executing “sudo apt-get install libmysql-ruby libmysqlclient-dev” will solve the problem.

rails 尚未安装

ubuntu linux使用gem安装rails后,在bash shell中无法使用rails命令,提示尚未安装。

此问题出现原因为PATH变量未更新。

解决方法:

1.更新文件数据库

sudo updatedb

2.查找rails安装路径

ocate rails | grep bin

3.建立快捷方式

ln -s /var/lib/gems/1.8/bin/rails /usr/bin/rails

ln -s /var/lib/gems/1.8/bin/rake /usr/bin/rake

the bundled mysql.rb driver has been removed from rails 2.2.

Rails 2.2 版本开始取出自带的 Mysql 支持,自带的 SQLite 没找到好用的可视化工具,所以还是选择老牌的 Mysql 比较舒服一些,如果选择 Mysql 需要手动设置一些地方。按照提示 gem install mysql 的结果往往是无法安装,以下提供 Windows 下的解决方案,Linux 用户应该也可以类似操作(未测试)。

  1. 首先下载老版本的 libmysql.dll 文件,libmysql
  2. 将此dll复制到ruby安装目录bin目录下
  3. 重新启动MySQL服务

操作完毕即可,如若使用 Netbeans 则需要指定 ruby 解释器为原版,jruby 按照此方法操作未见效果。