Rails readline安装

readline

在Centos上使用rails c 时,报错

[root@57-196 xxx]# rails c
/usr/local/lib/ruby/2.3.0/irb/completion.rb:10:in `require': cannot load such file -- readline (LoadError)
        from /usr/local/lib/ruby/2.3.0/irb/completion.rb:10:in `'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.0.3/lib/rails/commands/console.rb:3:in `require'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.0.3/lib/rails/commands/console.rb:3:in `'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.0.3/lib/rails/commands/commands_tasks.rb:138:in `require'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.0.3/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.0.3/lib/rails/commands/commands_tasks.rb:68:in `console'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.0.3/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-5.0.3/lib/rails/commands.rb:18:in `'
        from bin/rails:4:in `require'
        from bin/rails:4:in `
'

解决

  1. 安装centos的支持环境,参见linux环境初始脚本
  2. 编译ruby源码的readline
cd ///ext/readline
ruby extconf.rb

修改生成Makefile,添加 top_srcdir=../.. 内容如下

...
top_srcdir = ../..
CC = gcc
CXX = g++
LIBRUBY = $(LIBRUBY_A)
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) 
LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
empty =
OUTFLAG = -o $(empty)
COUTFLAG = -o $(empty)
...

安装

make && make install

你可能感兴趣的:(Rails readline安装)