You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级至Ubuntu 18.04后运行Rails Console出现报错

解决Ubuntu 18.04升级后Rails Console找不到libreadline.so.6的问题

Hey there, I’ve dealt with this exact headache after upgrading from Ubuntu 16.04 to 18.04—let’s get your Rails console back up and running!

What’s causing this?

Ubuntu 18.04 comes with libreadline7 preinstalled, but your Ruby 2.4.1 was compiled on 16.04, where the default readline library was libreadline6. The Rails console relies on readline for interactive input, so it’s throwing this missing file error. Puma doesn’t need this library just to start, which is why it works fine.

Since your Ruby was built against the old system libraries, reinstalling it will let it link against Ubuntu 18.04’s newer libraries:

  • First, update RVM to make sure you have the latest build scripts (optional but good practice):
    rvm get stable
    
  • Reinstall Ruby 2.4.1, which will rebuild it with current system dependencies:
    rvm reinstall ruby-2.4.1
    
  • Switch back to this freshly compiled Ruby version:
    rvm use ruby-2.4.1
    
  • Now fire up your Rails console again:
    rails c
    

This should resolve the issue for good. If you use rbenv instead of RVM, the process is similar—uninstall the old Ruby version and reinstall it with rbenv uninstall ruby-2.4.1 followed by rbenv install ruby-2.4.1.

If you don’t want to recompile Ruby right now, you can link the newer libreadline7 to the filename the old Ruby expects:

  • First confirm the path to libreadline.so.7 (this is usually the correct path for 64-bit systems):
    find /usr/lib -name libreadline.so.7
    
  • Create the symbolic link with sudo:
    sudo ln -s /usr/lib/x86_64-linux-gnu/libreadline.so.7 /usr/lib/x86_64-linux-gnu/libreadline.so.6
    
  • Try starting the Rails console again—it should work immediately. Just keep in mind this is a temporary fix; system updates might break this link later, so the recompilation method is better long-term.

内容的提问来源于stack exchange,提问作者James

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:50:25