升级ruby版本那"不堪回首的经历"

前段时间在玩Chef-一个IT基础设施自动化工具。由于Chef是由Ruby写的一个gem,那么就需要安装Ruby。当然Ruby我早就安装了,并且使用rvm来管理Ruby及Gem。本来一切看似正常,但是不会预料后面会遇到那么多的坑。

Chef本地的repo包中有一个vagrant虚拟机的模板文件,通过它可以setup一个虚拟机,然后使用Chef来操作这个节点。那么就使用vagrant命令来setup这个虚拟机把。

$ vagrant up --no-colorVagrant failed to initialize at a very early stage:It appears that you've ran a newer version of Vagrant on thiscomputer. Unfortunately, newer versions of Vagrant change internaldirectory layouts that cause older versions to break. This versionof Vagrant cannot properly run.If you'd like to start from a clean state, please remove theVagrant state directory: /Users/twer/.vagrant.dWarning that this will remove all your boxes and potentially corruptexisting Vagrant environments that were running based on the futureversion.

console中说Vagrant版本有问题,那么就按说明删除.vagrant.d文件夹把。

$ rm -rf ~/.vagrant.d/$ vagrant up --no-color/Users/twer/sourcecode/chef-repo/Vagrantfile:8:in `': undefined method `configure' for Vagrant:Module (NoMethodError)     from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/vagrant-1.0.7/lib/vagrant/config/loader.rb:115:in `load'     from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/vagrant-1.0.7/lib/vagrant/config/loader.rb:115:in `block in procs_for_source'     from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/vagrant-1.0.7/lib/vagrant/config.rb:41:in `block in capture_configures'

窝里个去,又出新问题了。那好吧,看看当前ruby的版本。

$ rvm listrvm rubies   ruby-1.9.2-p320 [ x86_64 ]=* ruby-1.9.3-p194 [ x86_64 ]# => - current# =* - current && default#  * - default

试着将Ruby的版本切换到1.9.2-p320再试试。

$ rvm use ruby-1.9.2-p320Using /usr/local/rvm/gems/ruby-1.9.2-p320$ vagrant upBringing machine 'default' up with 'virtualbox' provider...[default] Setting the name of the VM...[default] Clearing any previously set forwarded ports...[default] Creating shared folders metadata...[default] Clearing any previously set network interfaces...[default] Preparing network interfaces based on configuration...[default] Forwarding ports...[default] -- 22 => 2222 (adapter 1)[default] Booting VM...[default] Waiting for VM to boot. This can take a few minutes.[default] VM booted and ready for use![default] Setting hostname...[default] Mounting shared folders...[default] -- /vagrant

搞定。看来问题是当前使用的ruby的版本有问题。

老是使用旧版本也不是个事,把Ruby升级到最新版本看还有这个问题不。

$ rvm list known# MRI Rubies[ruby-]1.8.6[-p420][ruby-]1.8.7[-p374][ruby-]1.9.1[-p431][ruby-]1.9.2[-p320][ruby-]1.9.3[-p448][ruby-]2.0.0-p195[ruby-]2.0.0[-p247][ruby-]2.0.0-headruby-head

看来ruby的1.9.3已经有p448了,那么就升级到p448。

$ rvm install 1.9.3Checking requirements for osx.Installing requirements for osx.Updating system.Installing required packages: libksba, openssl..........Error running 'requirements_osx_brew_libs_install gcc libksba openssl',please read /usr/local/rvm/log/1379843991_ruby-1.9.3-p448/package_install_gcc_libksba_openssl.logRequirements installation failed with status: 1.

升级失败,那么看看log。

==> make bootstrapconfigure: error: cannot compute suffix of object files: cannot compileSee `config.log' for more details.make[2]: *** [configure-stage1-target-libgcc] Error 1make[1]: *** [stage1-bubble] Error 2make: *** [bootstrap] Error 2READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshootingThere were package installation errors, make sure to read the log.Try `brew tap --repair` and make sure `brew doctor` looks reasonable.

通过看log是gcc编译失败,并且通过log可以看出rvm是通过homebrew来安装必备文件的。

通过一番查资料后,找到了解决办法。那就是将Xcode升级到最新版本,然后在Preference里选择Downloads标签,然后安装Command Line Tools。

安装完毕后再用Homebrew安装gcc49。

123456789101112
$ brew install gcc49==> Downloading ftp://gcc.gnu.org/pub/gcc/snapshots/4.9-20130915/gcc-4.9-20130915.tar.bz2Already downloaded: /Library/Caches/Homebrew/gcc49-4.9-20130915.tar.bz2==> ../configure --build=x86_64-apple-darwin12.5.0 --prefix=/usr/local/Cellar/gcc49/4.9-20130915/gcc==> make bootstrap==> make install==> CaveatsThis is a snapshot of GCC trunk, which is in active development andsupposed to have bugs and should not be used in productionenvironment.==> Summary    

升级ruby版本那"不堪回首的经历"

相关文章:

你感兴趣的文章:

标签云: