可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I'm trying to install the rackspace plugin for vagrant (1.5.1):
vagrant plugin install vagrant-rackspace
But it complains
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
An error occurred while installing nokogiri (1.6.1), and Bundler
cannot continue. Make sure that gem install nokogiri -v '1.6.1'
succeeds before bundling.
However gem install nokogiri -v '1.6.1'
and /Applications/Vagrant/embedded/bin/gem install nokogiri -v '1.6.1'
both work.
I've looked at a bunch of SO threads and blog posts. Things I've tried that have not worked
- Running
xcode-select --install
- Installing full xcode
- brew install gcc-4.2
- Remove rvm and rvm version of ruby
- Install nokogiri w/ built-in (mac) ruby and vagrant-embedded ruby
Despite the fact that nokogiri installs fine (#5 above) without sudo on both counts, vagrant plugin install vagrant-rackspace
still fails...
So, in summary, I can install the nokogiri plugin, however I cannot install the vagrant rackspace plugin, can you help me get the plugin installed?
Related threads
- Error to install Nokogiri on OSX 10.9 Maverick?
- nokogiri - ERROR: Failed to build gem native extension
Full output of vagrant plugin install vagrant-rackspace --debug
回答1:
I'm on OSX Mavericks and this worked for me:
Set as environment property:
NOKOGIRI_USE_SYSTEM_LIBRARIES=1
Then install as usual:
vagrant plugin install vagrant-rackspace
回答2:
Vagrant ships with embedded Ruby and isolated gem environment. So installing gems manually to your "normal" gem environment won't help.
The first issue is that you should never use sudo to run any vagrant command. If possible, please remove ~/.vagrant.d/ or at least chown it recursively back to your own user. You could also try upgrading Vagrant to v1.5.1.
Then please gist/pastebin the output of vagrant plugin install vagrant-rackspace --debug
and ~/.vagrant.d/gems/gems/nokogiri-1.6.1/ext/nokogiri/mkmf.log.
回答3:
The posted solutions didn't work for me. Instead I needed to specify the libxml2, libxslt and libiconv that I installed with homebrew (Do this first).
I installed the gem manually with the embedded ruby with the following [very concise] command line:
/Applications/Vagrant/embedded/bin/gem install \ # select the embedded ruby
--install-dir ~/.vagrant.d/gems \ # install to the vagrant dir
nokogiri -v '1.6.2.1' -- \ # pass options to nokogiri install
--with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 \
--with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib \
--with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 \
--with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include \
--with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
回答4:
This worked for me on Mavericks and Vagrant 1.6.1:
CC=/usr/bin/gcc vagrant plugin install vagrant-rackspace
I tried NOKOGIRI_USE_SYSTEM_LIBRARIES=1
but got an error saying that system libxml2 is too old.
回答5:
Warning: This is a super-hacky solution, though it's hard to call it that.
Yesterday I installed Vagrant on another OSX Mavericks box. Like many other posts I read on SO "all I had to do" was run xcode-select --install
and bingo vagrant plugin install vagrant-rackspace
worked like a charm.
Today I was mired down in the Bundler code again when it dawned on me that since this is an isolated ruby environment why not nuke my ~/.vagrant.d
directory and copy the same directory from the successful build on the other box...
The result? A working vagrant rackspace
on my laptop! I'm not sure I'll ever figure out what was really wrong, but if anyone wants a shot at the 100 point bounty, I'm still open to suggestions!
回答6:
In my case the nokogiri folders and their files located in ~/vagrant.d/gems/gems
had wrong rights (user/group).
After changing them to username:staff
(username
being your console user name), it works like a charm.
回答7:
Similarly with my case, I have an issue while installing vagrant-omnibus
plugin for Vagrant 1.6.3 on OSX Mavericks 10.9.4 and ruby 2.0.0p247 rbenv.
I tried setting the env NOKOGIRI_USE_SYSTEM_LIBRARIES to 1 or true, then update+install but the same error still there.
I found that there is a suggestion in https://github.com/mitchellh/vagrant/issues/3769 to use the specify the baked in nokogiri version and this works for me. So, I also wrote a quick noted for myself to refer this unfortunates issue.
回答8:
If Nate Murray's solution doesn't work, I found upgrading to a Vagrant version > 1.6.4 fixed the issue (as noted in this Github issue: https://github.com/mitchellh/vagrant/issues/3769)