运行此命令时收到以下错误消息:
gem install rails -v 4.2.4
这是错误:
/Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/yaml.rb:5:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/psych.bundle, 9): Library not loaded: /usr/local/opt/libyaml/lib/libyaml-0.2.dylib (LoadError)
Referenced from: /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/psych.bundle
Reason: image not found - /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/psych.bundle
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/psych.rb:7:in `<top (required)>'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/yaml.rb:6:in `<top (required)>'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems.rb:628:in `load_yaml'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/config_file.rb:326:in `load_file'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/config_file.rb:198:in `initialize'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/gem_runner.rb:75:in `new'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/gem_runner.rb:75:in `do_configuration'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/gem_runner.rb:40:in `run'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/bin/gem:21:in `<main>'
请帮忙 - 这让我做恶梦
答案 0 :(得分:1)
看起来您的ruby安装缺少心理(对于YAML输出)。
使用 Homebrew 安装libyaml
:http://brew.sh;然后尝试gem install rails -v 4.2.4
$ brew info libyaml libyaml: stable 0.1.6 (bottled) YAML Parser http://pyyaml.org/wiki/LibYAML Not installed From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libyaml.rb ==> Options --universal Build a universal binary $ brew install libyaml ==> Downloading https://homebrew.bintray.com/bottles/libyaml-0.1.6_1.el_capitan.bottle.tar.gz ######################################################################## 100.0% ==> Pouring libyaml-0.1.6_1.el_capitan.bottle.tar.gz /usr/local/Cellar/libyaml/0.1.6_1: 8 files, 312.8K
重新安装RUBY
如果上述解决方案不适合您,请使用 rvm 或 rbenv 重新安装Ruby,
1)尝试接受此答案的说明:https://stackoverflow.com/a/38194139/1076207
-OR -
2)删除所有 rvm 文件,然后重新安装 rvm :https://stackoverflow.com/a/38158619/1076207
-OR -
3)删除所有 rvm 文件,然后安装 rbenv :https://stackoverflow.com/a/38194231/1076207
使用上述三个选项之一后,使用http://bundler.io安装Rails:
$ mkdir ~/Documents/Repo $ cd ~/Documents/Repo $ gem install bundler […] $ bundle init Writing new Gemfile to /Users/username/Documents/Repo/Gemfile $ echo "gem 'rails', '4.2.4'" >> Gemfile $ bundle install […] $ bundle exec rails new project_name […] $ cd project_name
就个人而言,我建议3)切换到rbenv-I。
答案 1 :(得分:0)
错误本身清楚地表明您应首先安装libyaml然后重新安装ruby。您可以通过运行以下命令来完成此操作。
sudo apt-get install libtool
rvm package install libyaml
rvm reinstall ruby-2.3.0
有关详情,请参阅this answer