最近重装了ubuntu, 于是打算用rvm来管理ruby环境.但是作为初学者,使用rvm还是遇到了很多问题.
今天打开rails c .突然跑步起来了.
$ rails c /home/congteng/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError) from /home/congteng/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/completion.rb:9:in `' from /home/congteng/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/commands/console.rb:3:in `require' from /home/congteng/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/commands/console.rb:3:in ` ' from /home/congteng/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/commands.rb:37:in `require' from /home/congteng/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/commands.rb:37:in ` ' from script/rails:6:in `require' from script/rails:6:in ` '
从报错信息看出是因为缺少了 readline的包支持.
于是到stackoverflow寻求解决方法
可是捣鼓了很久,上面的方法都不能够解决问题
其中有一个看似能解决问题的办法:
rvm pkg install readline rvm remove 1.9.3 rvm install 1.9.3 -C --with-openssl-dir=\$HOME/.rvm/usr,--with-iconv-dir=\$HOME/.rvm/usr, --with-readline-6.2-dir=\$HOME/.rvm/usr
但是依然没有起作用.
阅读了rvm官方文档:https://rvm.beginrescueend.com/packages/readline/
依旧是解决不了问题.
没办法,只有先放弃rvm.干脆在系统中直接安装配置readline了
找到rvm安装的ruby路径下的扩展readline文件夹
cd ~/.rvm/src/ruby-1.9.3-p180/ext/readline
ruby extconf.rb如果不能执行,说明需要安装如下包
sudo apt-get install libncurses5-dev libreadline5-dev
但是实践发现libreadline5-dev已经废弃了
可根据提示安装
重新运行
ruby extconf.rb
这时所有的都是yes
继续make
make install
--> http://stackoverflow.com/questions/5487507/rails3-and-readline-problem