rails console 提示 “cannot load such file -- readline”

   最近在centos下安装rails环境,安装过程中并无报错,但是在启动rails c时提示如下报错:

Traceback (most recent call last):
bin/rails: Bootsnap::LoadPathCache::FallbackScan
	43: from bin/rails:4:in `<main>'
	42: from /opt/ruby/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
	41: from /opt/ruby/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
	40: from /opt/ruby/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
	39: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
	38: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
	37: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	36: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
	35: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
	34: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/commands.rb:18:in `<main>'
	33: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command.rb:44:in `invoke'
	32: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command.rb:70:in `find_by_namespace'
	31: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command/behavior.rb:79:in `lookup'
	30: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command/behavior.rb:79:in `each'
	29: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command/behavior.rb:80:in `block in lookup'
	28: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command/behavior.rb:80:in `each'
	27: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command/behavior.rb:84:in `block (2 levels) in lookup'
	26: from /opt/ruby/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
	25: from /opt/ruby/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
	24: from /opt/ruby/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
	23: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
	22: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
	21: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	20: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
	19: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
	18: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/commands/console/console_command.rb:4:in `<main>'
	17: from /opt/ruby/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
	16: from /opt/ruby/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
	15: from /opt/ruby/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
	14: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
	13: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
	12: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	11: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
	10: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
	 9: from /opt/ruby/lib/ruby/2.6.0/irb/completion.rb:10:in `<main>'
	 8: from /opt/ruby/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
	 7: from /opt/ruby/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
	 6: from /opt/ruby/lib/ruby/gems/2.6.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
	 5: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:26:in `require'
	 4: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:40:in `rescue in require'
	 3: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
	 2: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
	 1: from /opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/opt/ruby/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': cannot load such file -- readline (LoadError)

一开始百度时候被“bootsnap”这个关键字带入坑里,搜索到都是关于“bootsnap”这个gem包版本的问题,修改删除相关临时文件都无用。最后直接在“config/boot.rb”这个配置文件中删除了对bootsnap的使用,还是报错。报错内容如下:

Traceback (most recent call last):
	14: from bin/rails:4:in `<main>'
	13: from bin/rails:4:in `require'
	12: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/commands.rb:18:in `<top (required)>'
	11: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command.rb:44:in `invoke'
	10: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command.rb:70:in `find_by_namespace'
	 9: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command/behavior.rb:79:in `lookup'
	 8: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command/behavior.rb:79:in `each'
	 7: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command/behavior.rb:80:in `block in lookup'
	 6: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command/behavior.rb:80:in `each'
	 5: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command/behavior.rb:84:in `block (2 levels) in lookup'
	 4: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/command/behavior.rb:84:in `require'
	 3: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/commands/console/console_command.rb:4:in `<top (required)>'
	 2: from /opt/ruby/lib/ruby/gems/2.6.0/gems/railties-5.2.2/lib/rails/commands/console/console_command.rb:4:in `require'
	 1: from /opt/ruby/lib/ruby/2.6.0/irb/completion.rb:10:in `<top (required)>'
/opt/ruby/lib/ruby/2.6.0/irb/completion.rb:10:in `require': cannot load such file -- readline (LoadError)

这会的报错更接近真实答案了,百度后得出结论是rails 找不到readline这个库(readline是用于命令自动补全的)。我检查了操作系统系统应该是已经装了该包,至于为何找不到我也不得而知,百度上否是乌班图系统遇到该问题。最后在网上找到这个gem包:https://rubygems.org/gems/rb-readline 看来大家都有遇到一样问题,安装此工具包就可以解决该问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值