Ruby-on-rails 库未加载:/usr/local/opt/readline/lib/libreadline.7.dylib

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/54261455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 08:54:50  来源:igfitidea点击:

Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib

ruby-on-railslibreadline

提问by Jonathan Tuzman

When I try running rails consoleI get this error:

当我尝试运行时,出现rails console此错误:

/Users/TuzsNewMacBook/.rvm/gems/ruby-2.3.7/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require':
 dlopen(/Users/TuzsNewMacBook/.rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/x86_64-darwin18/readline.bundle, 9): 
Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)

A quick search got me to this postand I've tried a few things:

快速搜索让我找到了这篇文章,我尝试了一些方法:

brew reinstall postgresql(this is indeed the DB for this project)

brew reinstall postgresql(这确实是这个项目的数据库)

and

cd /usr/local/opt/readline/lib    
ln libreadline.8.0.dylib libreadline.6.2.dylib

(my version of readline is 8)

(我的 readline 版本是 8)

and brew link readline --force

brew link readline --force

But none of these have fixed it.

但这些都没有修复它。

I recently added pry-coolline, guardand guard-livereloadgems to my project if that makes any difference (rails console loaded fine before those). I'm running on the latest macos.

我最近将pry-coolline,guardguard-livereloadgems添加到我的项目中,如果这有什么不同的话(rails 控制台在这些之前加载得很好)。我正在运行最新的 macos。

(Update) I'm using pry rails as my rails console, if that makes any difference.

(更新)我使用撬轨作为我的导轨控制台,如果这有什么不同的话。

Any help? Thanks.

有什么帮助吗?谢谢。

回答by Hawz

the error seems to be thrown when searching for /usr/local/opt/readline/lib/libreadline.7.dylib.

搜索/usr/local/opt/readline/lib/libreadline.7.dylib.

Have you tried to symlink that?

你试过符号链接吗?

So something like:

所以像:

cd /usr/local/opt/readline/lib 
ln -s libreadline.8.0.dylib libreadline.7.dylib

Just tried that on macOS Mojave, ruby 2.5.3p105 and Rails 5.2.2 and worked.

刚刚在 macOS Mojave、ruby 2.5.3p105 和 Rails 5.2.2 上尝试过,并且工作正常。

回答by Jonathan Tuzman

Reinstalling my Ruby version seems to have fixed it:

重新安装我的 Ruby 版本似乎已修复它:

rvm reinstall 2.3.7

回答by ericshao

can you try

你能试一下吗

cd /usr/local/opt/readline/lib    
ln -s libreadline.8.dylib libreadline.7.dylib

you are on the right track but it seems like rails is looking for libreadline.7.dylib and libreadline.7.dylib is not there in the folder.

你在正确的轨道上,但似乎 rails 正在寻找 libreadline.7.dylib 而 libreadline.7.dylib 不在文件夹中。

回答by FreePender

Yes, the best answer is to reinstall.

是的,最好的答案是重新安装。

You can get the version easily by typing:

您可以通过键入以下内容轻松获取版本:

ruby -v

With rbenv, the command is i.e.:

使用rbenv,命令是:

rbenv install 2.3.7

with rvm:

rvm

rvm reinstall 2.3.7

回答by Frederik Spang

Most often in Ruby-applications, this is caused by gems that have extensions (the gems saying "Building native extensions.."), that are built using a specific version of, in this case, readline.

大多数情况下,在 Ruby 应用程序中,这是由具有扩展名的 gems(gems 说“构建本机扩展..”)引起的,这些 gems 是使用特定版本构建的,在这种情况下是readline.

Basically, there are two solutions:

基本上,有两种解决方案:

Either, you can symlink version 8 of the gem, to the version missing. This will work in many cases, but if backwards compatibility is broken, it will not.

或者,您可以将 gem 的第 8 版符号链接到缺少的版本。这在许多情况下都有效,但如果向后兼容性被破坏,则不会。

Or, if the gem actually supports version 8, you can reinstall that specific gem, or "pristine" it by running gem pristine --all.

或者,如果 gem 实际上支持第 8 版,您可以重新安装该特定 gem,或者通过运行gem pristine --all.

EDIT: In scope of your "what I've tried", reinstalling PostgreSQL, is also one of the binaries, built using a specific version, that may also require a rebuild, to work with a system library, such as readline.

编辑:在您的“我尝试过的”范围内,重新安装 PostgreSQL 也是使用特定版本构建的二进制文件之一,可能还需要重建,以使用系统库,例如 readline。

回答by Aris

Got this issue:

得到这个问题:

dyld: Library not loaded: /usr/local/opt/mpfr/lib/libmpfr.4.dylib

doing...

正在做...

cd /usr/local/opt/mpfr/lib/
ln -s libmpfr.dylib libmpfr.4.dylib

did the trick for me for macOS Catalina

为我在 macOS Catalina 上成功

回答by Bret Weinraub

A very simple solution that doesn't involve rebuilding your RVM gemset OR sym-linking libraries.

一个非常简单的解决方案,不涉及重建 RVM gemset 或符号链接库。

Add to your Gemfile:

添加到您的 Gemfile:

gem 'rb-readline'

If you are doing bundler groups

如果你在做捆绑组

group :development do
  gem 'rb-readline'
end

Then run

然后运行

> bundle

Let me know if that doesn't work.

如果这不起作用,请告诉我。

回答by Salyangoz

So Ive checked a few answers here but I dont think they can work with a vanilla Mojave mac install. Im using 10.14.4 while I did these:

所以我在这里检查了一些答案,但我认为它们不能与 vanilla Mojave mac 安装一起使用。我在做这些时使用 10.14.4:

  • get homebrew from https://brew.sh

  • $ brew install coreutils: this installs the gnu coreutils pkg for mac, we want the greadlinkfrom this because macOSX's readlink is not the same as the gnu readlink. Its extremely confusing but such is the life in macland.

  • $ echo 'alias readlink=greadlink' >> ~/.bash_aliasesI found macs readlink to be a bit lacking so I overrode the existing readlink by aliasing greadlink. (you can make this usable by all users by $ alias readlink=greadlink >> /etc/bashrcwhich will enable every user to be able to use it.

  • $ ln -s /usr/local/opt/readline/lib/libreadline.8.dylib /usr/local/opt/readline/lib/libreadline.7.dylibI linked the already linked .8.file instead of '.8.0.' file because if it were to get updated to .8.1.then my readlink wont break or miss features on the library. Im pretty sure we will format our macs before 9+ comes out.

  • https://brew.sh获取自制软件

  • $ brew install coreutils:这会为 mac 安装 gnu coreutils pkg,我们希望greadlink从这里下载,因为 macOSX 的 readlink 与 gnu readlink 不同。它非常令人困惑,但这就是麦克兰德的生活。

  • $ echo 'alias readlink=greadlink' >> ~/.bash_aliases我发现 macs readlink 有点缺乏,所以我通过别名 greadlink 覆盖了现有的 readlink。(您可以使所有用户$ alias readlink=greadlink >> /etc/bashrc都可以使用它,这将使每个用户都能够使用它。

  • $ ln -s /usr/local/opt/readline/lib/libreadline.8.dylib /usr/local/opt/readline/lib/libreadline.7.dylib我链接了已经链接的.8.文件而不是“.8.0”。文件,因为如果它被更新到.8.1.那么我的阅读链接不会中断或错过库中的功能。我很确定我们会在 9+ 出现之前格式化我们的 mac。

回答by codenamev

I would recommend against manually symlink'ing native libraries. Aas of OS X 10.4, the standard include library path /usr/includeis no longer used and is locked by SIP (making it difficult to move things to).

我建议不要手动符号链接本地库。从 OS X 10.4 开始,/usr/include不再使用标准包含库路径并被 SIP 锁定(使其难以移动)。

Apple ships a “legacy installer” for you to be able to install the headers in the “old location”, which will also resolve your path to correctly find headers installed via brew.

Apple 提供了一个“旧版安装程序”,您可以将头文件安装在“旧位置”,这也将解析您的路径以正确查找通过brew.

cp /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg ~/Desktop && open ~/Desktop/macOS_SDK_headers_for_macOS_10.14.pkg`

See here for a detailed write-up on what is going on.

有关正在发生的事情的详细说明,请参见此处

回答by Benjamín Valero

My problem was just the same when running lftp.

运行时我的问题是一样的lftp

Just running brew upgradehas solved my problem, as it has updated (among others):

刚刚运行brew upgrade解决了我的问题,因为它已经更新(以及其他):

readline 8.0.0_1 -> 8.0.1
lftp 4.8.4 -> 4.8.4_2