简体   繁体   English

升级到Ubuntu 18.04后的Rails Console错误

[英]Rails Console error after upgrading to Ubuntu 18.04

After upgrading from ubuntu 16.04 to ubuntu 18.04 I am receiving the following error when running rails console from the root directory of rails project. 从ubuntu 16.04升级到ubuntu 18.04后,从rails项目的根目录运行rails console时收到以下错误。 Only the console seems to be affected, I am able to start the puma server without issue. 只有控制台似乎受到了影响,我能够毫无问题地启动puma服务器。

Running via Spring preloader in process 23887
/home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require': libreadline.so.6: cannot open shared object file: No such file or directory - /home/user/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/x86_64-linux/readline.so (LoadError)
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
    from /home/user/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/irb/completion.rb:10:in `<top (required)>'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/railties-5.1.6/lib/rails/commands/console/console_command.rb:2:in `<top (required)>'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/railties-5.1.6/lib/rails/command/behavior.rb:82:in `block (2 levels) in lookup'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/railties-5.1.6/lib/rails/command/behavior.rb:78:in `each'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/railties-5.1.6/lib/rails/command/behavior.rb:78:in `block in lookup'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/railties-5.1.6/lib/rails/command/behavior.rb:77:in `each'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/railties-5.1.6/lib/rails/command/behavior.rb:77:in `lookup'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/railties-5.1.6/lib/rails/command.rb:68:in `find_by_namespace'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/railties-5.1.6/lib/rails/command.rb:42:in `invoke'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<top (required)>'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
    from /home/user/dev/projects/SRTrackerMySQL/bin/rails:9:in `<top (required)>'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `block in load'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
    from /home/user/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load'
    from /home/user/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    from /home/user/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    from -e:1:in `<main>'

I've run bundle install and tried it with new rails projects with both Rails 5.1.6 and Rails 5.2 我已经运行了bundle install并在Rails 5.1.6Rails 5.2新Rails项目中进行了尝试

I also tried running RAILS_ENV=production bundle exec rails console 我也尝试过运行RAILS_ENV=production bundle exec rails console

I'm using Ruby version: 我正在使用Ruby版本:

ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]

You need to make sure readline is installed. 您需要确保已安装readline。 You're using RVM, so you can run: 您正在使用RVM,因此可以运行:

rvm requirements

and it should help make sure you have everything installed that you need, followed by: 并且应该有助于确保已安装所需的所有内容,然后执行以下操作:

rvm reinstall 2.4.1

if needed to make sure your ruby is good to go. 如果需要确保您的红宝石很好走。

I had the same exact issue but we use rbenv instead of rvm . 我有完全相同的问题,但是我们使用rbenv而不是rvm A similar answer to Brian's worked for me: 对Brian为我工作的类似答案:

rbenv uninstall 2.4.1
rbenv install 2.4.1

I had the same problem after upgrading. 升级后我遇到了同样的问题。 My guess is the problem happens with the RVM. 我的猜测是RVM会发生问题。

so, first uninstall the RVM. 因此,首先卸载RVM。

rvm implode

And then, do the following commands to install the RVM again 然后,执行以下命令以再次安装RVM

sudo apt install gnupg2
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
cd /tmp
curl -sSL https://get.rvm.io -o rvm.sh
less /tmp/rvm.sh
cat /tmp/rvm.sh | bash -s stable --rails
source /home/admat/.rvm/scripts/rvm

Reload the RVM 重新加载RVM

rvm reload

Install your ruby version 安装你的ruby版本

rvm install _version_

Don the bundle command to install gems 不要使用bundle命令安装gem

bundle install

DONE !!!!! 完成!!!!!

if you want more details on installing ruby to ubuntu 18.04, try the following link Install ruby on rails with Ubuntu 18.04 如果您想了解有关将Ruby安装到ubuntu 18.04的更多详细信息,请尝试以下链接使用Ubuntu 18.04在轨道上安装Ruby

I also was not able to run rails console after upgrading Ubuntu from 16.04 to 18.04. 将Ubuntu从16.04升级到18.04后,我也无法运行rails console I was getting something similar to this: 我得到了类似的东西:

-bash: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory

I had to reinstall rvm again following the instructions posted here: https://github.com/rvm/ubuntu_rvm 我不得不按照此处发布的说明再次重新安装rvm: https : //github.com/rvm/ubuntu_rvm

Reinstalling Ruby and rehashing rbenv didn't work for me. 重新安装Ruby和重新哈希rbenv对我不起作用。 In the end I went for a simple symlink of the current installed libreadline.so7 最后,我使用了当前安装的libreadline.so7的简单符号链接

locate libreadline.so

This returned a whole list of possible options, but the most likely usable one appeared to be /lib/x86_64-linux-gnu/libreadline.so.7 这返回了可能选项的完整列表,但是最可能使用的选项似乎是/lib/x86_64-linux-gnu/libreadline.so.7

sudo ln -s /lib/x86_64-linux-gnu/libreadline.so.7 /lib/x86_64-linux-gnu/libreadline.so.6

Once linked, I can now run rails console and use byebug again. 链接后,我现在可以运行rails console并再次使用byebug

Running the following code on the terminal solved the problem for me: 在终端上运行以下代码为我解决了这个问题:

cd /lib/x86_64-linux-gnu
sudo ln -s libreadline.so.7.0 libreadline.so.6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM