做rails项目的时候用到mysql2,上次装的时候出现了问题。今天又遇到了,这里写下。
出现的问题是Failed to build gem native extension。其实应该显示gem install mysql的,但是也会出现类似的问题。其实原因就是缺少依赖包。只要做执行sudo apt-get install libmysqlclient-dev 就可以了。然后bundle install。今天遇到的问题是源的问题。因为Linux源比较旧倒是不能安装依赖。总是提示,不能找到包。所以更新一下源。下面是我用的源 大家可以试着用下
sudo vi /etc/apt/source.list 打开这个文件以后删掉里面的所有。然后将下面的代码粘贴过去,就可以了。
deb http://packages.linuxmint.com/ nadia main upstream import
deb http://archive.ubuntu.com/ubuntu/ quantal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ quantal-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ quantal-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu/ quantal partner
deb http://packages.medibuntu.org/ quantal free non-free
#deb http://archive.getdeb.net/ubuntu quantal-getdeb apps
#deb http://archive.getdeb.net/ubuntu quantal-getdeb games
另外说一下 mysql2 和mysql 没有依赖关系,安装mysql2不必一定安装mysql。