如何解决“ruby 安装丢失心理”错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9434002/
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 02:53:49  来源:igfitidea点击:

how to solve "ruby installation is missing psych" error?

ruby-on-railsrubymacosrvm

提问by Pouya

I used rvm to install ruby 1.9.3. even though it was successfully installed, it complained about libyaml. and now every time i wanna install a gem (say rails) this warning shows up:

我使用 rvm 安装 ruby​​ 1.9.3。即使它已成功安装,它也会抱怨 libyaml。现在每次我想安装 gem(比如 rails)时都会出现这个警告:

It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby.

I use Mac os X 10.7 (Lion).

我使用 Mac os X 10.7 (Lion)。

回答by peterpengnz

In my case

就我而言

rvm pkg install libyaml

and

rvm reinstall ruby-1.9.3-p125

solved the problem.

解决了这个问题。

For people using Ubuntu, make sure that libtoolis installed prior to the steps above:

对于使用 Ubuntu 的人,请确保libtool在执行上述步骤之前已安装:

sudo apt-get install libtool

For macOS users (with homebrew):

对于 macOS 用户(使用自制软件):

rm -rf /usr/local/lib/ruby/gems/ && brew reinstall ruby

回答by Gizmomogwai

for ubuntu and rvm

对于 ubuntu 和 rvm

sudo apt-get install libtool
rvm pkg install libyaml
rvm reinstall 1.9.3

worked

工作过

回答by matt

If not using rvm, but rather you are building and installing ruby 1.9.3 from scratch — for example, you're managing your ruby versions with rbenv— you must install libyaml first. Get it from http://pyyaml.org/; at the moment, the file you want is http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz. Open the tarball and cd into the resulting folder. Then:

如果不使用 rvm,而是从头开始构建和安装 ruby​​ 1.9.3 — 例如,您正在使用rbenv管理您的 ruby​​ 版本— 您必须先安装 libyaml。从http://pyyaml.org/获取;目前,您想要的文件是http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz。打开 tarball 并 cd 进入生成的文件夹。然后:

./configure --prefix=/usr/local
make
sudo make install

You are now ready to build ruby. Download ruby from http://ftp.ruby-lang.org/pub/ruby/. Open the tarball and cd into the resulting folder. Now:

您现在已准备好构建 ruby​​。从http://ftp.ruby-lang.org/pub/ruby/下载 ruby 。打开 tarball 并 cd 进入生成的文件夹。现在:

./configure --prefix=/wherever/you/want/it/to/go
make
make install

(Or possibly sudo make install, depending on where you're putting it.) If using rbenv, you'll know it has worked if you switch to rbenv global 1.9.3-p194(or whatever your version is called) and gem --versionworks without a warning. That worked for me on Mac OS X 10.6.8. (Update: I just tried this on Mac OS X 10.8.1 and it seems to have worked fine there too.)

(或者可能sudo make install,取决于你把它放在哪里。)如果使用 rbenv,如果你切换到rbenv global 1.9.3-p194(或任何你的版本调用),你就会知道它已经工作并且gem --version没有警告。这在 Mac OS X 10.6.8 上对我有用。(更新:我刚刚在 Mac OS X 10.8.1 上尝试过这个,它似乎在那里也运行良好。)

回答by Catharz

brew install libyaml
rvm reinstall 1.9.3

Is what worked for me (on Snow Leopard).

是什么对我有用(在雪豹上)。

回答by Vanuan

In my case the solution was to add the psychgem to the Gemfile.

就我而言,解决方案是将psychgem添加到 Gemfile 中。

回答by AKWF

I had this problem. libyaml wouldn't compile. It turns out I was missing libtool.

我有这个问题。libyaml 不会编译。事实证明我缺少 libtool。

yum install libtool
yum install libyaml (or rvm pkg install libyaml)
rvm reinstall 1.9.3

That solved my problem.

那解决了我的问题。

回答by Lane

$ brew doctor
$ brew link libyaml

回答by orkoden

If you have installed ruby on macOS with homebrew, try this solution.

如果你已经在 macOS 上用 homebrew 安装了 ruby​​,试试这个解决方案

rm -rf /usr/local/lib/ruby/gems/ && brew reinstall ruby

rm -rf /usr/local/lib/ruby/gems/ && brew reinstall ruby

Note that this will get rid of all installed gems. Best save a list of installed gems with gem listbefore you run this.

请注意,这将删除所有已安装的 gem。最好gem list在运行之前保存已安装的 gem 列表。

回答by Michael

I got this fixed finally. The issue was that even though I installed libyaml with brew, it was never linked. I had to remove a conflicting header file and then brew link libyaml.

我终于解决了这个问题。问题是,即使我用 brew 安装了 libyaml,它也从未链接过。我不得不删除一个冲突的头文件,然后brew link libyaml.

回答by user33302

Installing ruby with rvm for mac osx, use autolibs to install libyaml and first uninstalling libyaml helps.

使用 rvm for mac osx 安装 ruby​​,使用 autolibs 安装 libyaml 并首先卸载 libyaml 有帮助。

This worked for me:

这对我有用:

brew uninstall libyaml
rvm autolibs enable
rvm reinstall ruby-2.1.1