美文网首页Ruby程序员
Rails readline安装

Rails readline安装

作者: ahtest | 来源:发表于2017-07-20 09:41 被阅读40次

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 `<top (required)>'
        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 `<top (required)>'
        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 `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

解决

  1. 安装centos的支持环境,参见linux环境初始脚本
  2. 编译ruby源码的readline
cd /<path>/<ruby>/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安装

    本文链接:https://www.haomeiwen.com/subject/gcjrkxtx.html