我已经把头发拉了整整 24 小时了。我搜索了高低寻找解决方案。我已经尝试了几乎所有我能找到的东西。
我想要做什么:
为'knife'程序安装ec2插件;与 Chef 服务器交互的宝贵工具。
会发生什么
一切都会带着彩虹和 unicorn 回来。 module installed
。模块不可用,我也找不到任何证据表明它已成功安装。
我的环境 :
详细信息在这篇文章的末尾。
高级:安装了 BREW 的 OSX 10.9.2 以及 Xcode 5.1
最简单的方法是展示我的问题:
尝试安装 gem
bash-3.2$ sudo -E gem install knife-ec2
Fetching: knife-windows-0.5.15.gem (100%)
Successfully installed knife-windows-0.5.15
Fetching: knife-ec2-0.8.0.gem (100%)
Successfully installed knife-ec2-0.8.0
Parsing documentation for knife-windows-0.5.15
Installing ri documentation for knife-windows-0.5.15
Parsing documentation for knife-ec2-0.8.0
Installing ri documentation for knife-ec2-0.8.0
2 gems installed
太棒了!它已安装。整洁的。那很简单!
等一下
bash-3.2$ knife ec2
FATAL: Cannot find sub command for: 'ec2'
The ec2 commands were moved to plugins in Chef 0.10
You can install the plugin with `(sudo) gem install knife-ec2
bash-3.2$ sudo knife ec2
FATAL: Cannot find sub command for: 'ec2'
The ec2 commands were moved to plugins in Chef 0.10
You can install the plugin with `(sudo) gem install knife-ec2
它不能作为 root 或普通用户使用。
经过更多阅读,(部分参见此处 How to install knife-ec2 ),我尝试了不同的方法
bash-3.2$ cd /opt/chef/embedded/bin/
bash-3.2$ sudo ./gem install knife-ec2
Building native extensions. This could take a while...
ERROR: Error installing knife-ec2:
ERROR: Failed to build gem native extension.
/opt/chef/embedded/bin/ruby extconf.rb
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin13.1.0/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... OK
Running 'compile' for libxml2 2.8.0... OK
Running 'install' for libxml2 2.8.0... OK
Activating libxml2 2.8.0 (from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.1.0/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin13.1.0/ports/libxslt/1.1.26... OK
Running 'configure' for libxslt 1.1.26... OK
Running 'compile' for libxslt 1.1.26... OK
Running 'install' for libxslt 1.1.26... OK
Activating libxslt 1.1.26 (from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.1.0/libxslt/1.1.26)...
checking for libxml/parser.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/chef/embedded/bin/ruby
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-pkg-config
--without-pkg-config
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-libiconv-config
--without-libiconv-config
--with-pkg-config
--without-pkg-config
/opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:983:in `block in find_header'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /opt/chef/embedded/lib/ruby/1.9.1/mkmf.rb:982:in `find_header'
from extconf.rb:166:in `<main>'
Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.1 for inspection.
Results logged to /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.1/ext/nokogiri/gem_make.out
尝试与上述相同的方法,但具有常规用户访问权限
bash-3.2$ ./gem install knife-ec2
Fetching: nokogiri-1.6.1.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /opt/chef/embedded/lib/ruby/gems/1.9.1 directory.
有关我的 ruby 设置的更多信息
bash-3.2$ rvm -v
rvm 1.25.22 (master) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
bash-3.2$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
下面是一个
env
列表。希望这会对您有所帮助。bash-3.2$ env
TERM_PROGRAM=iTerm.app
SHELL=/bin/bash
TERM=xterm
TMPDIR=/var/folders/m7/x_zjzw412rvg7rb_gz8135m5_0892r/T/
Apple_PubSub_Socket_Render=/tmp/launch-bEYnaW/Render
CDC_PREW2KHOST=<xOMITTEDx>
AWS_AVAILABILITY_REGION=us-west-1
OLDPWD=/tmp
COM_GOOGLE_CHROME_FRAMEWORK_SERVICE_PROCESS/USERS/<xOMITTEDx>/LIBRARY/APPLICATION_SUPPORT/GOOGLE/CHROME_SOCKET=/tmp/launch-KSHJfT/ServiceProcessSocket
USER=<xOMITTEDx>
AWS_AVAILABILITY_ZONE=us-west-1a
SSH_AUTH_SOCK=/tmp/launch-lUS8iG/Listeners
__CF_USER_TEXT_ENCODING=0x54042458:0:0
AWS_SSH_KEY_PAIR=<xOMITTEDx>
PATH=/Users/<xOMITTEDx>/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
__CHECKFIX1436934=1
PWD=/tmp/libxslt-1.1.28
EDITOR=/usr/bin/nano
AWS_SECRET_ACCESS_KEY=<xOMITTEDx>
LANG=en_US.UTF-8
ITERM_PROFILE=Default
USER_PRINCIPAL_NAME=<xOMITTEDx>@CORP.ACXIOM.NET
CDC_JOINED_DC=fsccorpdc01.corp.acxiom.net
AWS_ACCESS_KEY_ID=<xOMITTEDx>
HOME=/Users/<xOMITTEDx>
COLORFGBG=7;0
SHLVL=2
CDC_JOINED_SITE=<xOMITTEDx>
ITERM_SESSION_ID=w0t1p0
LOGNAME=<xOMITTEDx>
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future
CDC_JOINED_ZONE=DC=corp,DC=acxiom,DC=net
CDC_LOCALHOST=<xOMITTEDx>0214mac.corp.acxiom.net
AWS_ACCESS_KEY=<xOMITTEDx>
AWS_SECRET_KEY=<xOMITTEDx>
CDC_JOINED_DOMAIN=corp.acxiom.net
_=/usr/bin/env
bash-3.2$ sudo env
TERM=xterm
SSH_AUTH_SOCK=/tmp/launch-lUS8iG/Listeners
__CF_USER_TEXT_ENCODING=0x54042458:0:0
PATH=/Users/<xOMITTEDx>/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
EDITOR=/usr/bin/nano
LANG=en_US.UTF-8
HOME=/Users/<xOMITTEDx>
COLORFGBG=7;0
SHELL=/bin/bash
MAIL=/var/mail/root
LOGNAME=root
USER=root
USERNAME=root
SUDO_COMMAND=/usr/bin/env
SUDO_USER=<xOMITTEDx>
SUDO_UID=1409557592
SUDO_GID=20
最佳答案
我遇到了同样的问题,但使用了不同的插件。
这让它为我工作:knife
无法找到插件,尽管它说它会寻找 gem install
"ed"的插件。我认为问题在于 rvm
部分,并且 gems 安装在与平时完全不同的文件夹中:
~/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/
您可以使用
gem env
命令进行检查$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2012-02-16 patchlevel 125) [x86_64-darwin12.5.0]
- INSTALLATION DIRECTORY: /Users/phil/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /Users/phil/.rbenv/versions/1.9.3-p125/bin/ruby
- EXECUTABLE DIRECTORY: /Users/phil/.rbenv/versions/1.9.3-p125/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /Users/phil/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1
- /Users/phil/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
所以我像这样将 gem 链接到我的
~/.chef/plugins/knife
文件夹:$ ln -s ~/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/knife-digital_ocean-0.7.0 ./knife-digital_ocean-0.7.0
$ ln -s ~/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/knife-solo-0.4.2 ./knife-solo-0.4.2
现在
knife
能够找到插件了:$ knife digital_ocean
FATAL: Cannot find sub command for: 'digital_ocean'
Available digital_ocean subcommands: (for details, knife SUB-COMMAND --help)
** DIGITAL_OCEAN COMMANDS **
knife digital_ocean droplet create (options)
knife digital_ocean droplet destroy (options)
knife digital_ocean droplet list (options)
knife digital_ocean image list (options)
knife digital_ocean region list (options)
knife digital_ocean size list (options)
knife digital_ocean sshkey list
也应该适用于 ec2 插件...
关于ruby/OSX 10.9.2 : chef plugin knife-ec2 installs successfully, 但仍然不可用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22719599/