helen's blog

ぽんこつによるぽんこつのためのぽんこつブログ

railsのバージョンを確認しただけなのにWarningがでた件

$ rails -v
Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
Rails 4.2.5.1

Rails 4.2.5.1とRubyGems2.0.14使ってるけど
2.1.0以上にアップグレードして"gem pristine --all"したほうが効率良くなるよ
って言われてる

gem pristineとは
$ gem pristine -h
  
  Summary:
    Restores installed gems to pristine condition from files located in the gem cache

  Description:
    The pristine command compares an installed gem with the contents of its cached .gem file 
    and restores any files that don't match the cached .gem's copy.

    If you have made modifications to an installed gem, the pristine command
    will revert them.  All extensions are rebuilt and all bin stubs for the gem
    are regenerated after checking for modifications.

    If the cached gem cannot be found it will be downloaded.

    If --no-extensions is provided pristine will not attempt to restore a gem
    with an extension.

ざっくり読むと

  • pristineをすると、インストールされたgemとgemのキャッシュを比較し、もし一致しなければキャッシュされたものを復元する
  • インストールしたgemに変更を加えていた場合、pristineコマンドは戻してしまう
  • すべての再構築と変更を確認した後のgemの再構築する
  • キャッシュされたgemが見つからなかった場合はダウンロードされる
  • --no-extensionsをつけるとgemの拡張を復元しない

らしい

つまりgem pristineで
ローカルのgemのキャッシュからインストール済みのgemの状態に復元してくれるらしい

まずrubygemsのバージョンをあげる

$ gem update -h
  Options:
        --system [VERSION]           Update the RubyGems system software

# --system "バージョン番号" で指定したバージョンにあげられる

$ gem update --system 2.1.0
Updating rubygems-update
Fetching: rubygems-update-2.1.0.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

# sudo した
$ sudo gem update --system 2.1.0                                                      
Password:
Updating rubygems-update
Fetching: rubygems-update-2.1.0.gem (100%) # これ
Successfully installed rubygems-update-2.1.0
Parsing documentation for rubygems-update-2.1.0
Installing ri documentation for rubygems-update-2.1.0
Installing darkfish documentation for rubygems-update-2.1.0
Done installing documentation for rubygems-update after 2 seconds
Installing RubyGems 2.1.0
RubyGems 2.1.0 installed
Parsing documentation for rubygems-2.1.0
Installing ri documentation for rubygems-2.1.0


------------------------------------------------------------------------------

RubyGems installed the following executables:
	/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/gem

Ruby Interactive (ri) documentation was installed. ri is kind of like man # ri?
pages for ruby libraries. You may access it like this:
  ri Classname
  ri Classname.class_method
  ri Classname#instance_method
If you do not wish to install this documentation in the future, use the
--no-document flag, or set it as the default in your ~/.gemrc file. See
'gem help env' for details.

RubyGems system software updated

アップデートしたらなにかインストールされた

Ruby Interactive (ri) documentation

クラスやメソッドなどのドキュメントを見れる

もし今後インストールしてほしくなかったら
--no-document flagをつけるか.gemrcに設定すればいいらしい

そしてpristine

$ sudo gem pristine --all 
Restoring gems to pristine condition...
Restored CFPropertyList-2.2.8
Restored actionmailer-4.2.5.1
Restored actionpack-4.2.5.1
Restored actionview-4.2.5.1
Restored activejob-4.2.5.1
Restored activemodel-4.2.5.1
Restored activerecord-4.2.5.1
Restored activesupport-4.2.5.1
Restored arel-6.0.3
Skipped bigdecimal-1.2.0, it is a default gem
Building native extensions.  This could take a while...
Restored binding_of_caller-0.7.2
Restored builder-3.2.2
Restored bundler-1.11.2
Restored bundler-1.8.4
Building native extensions.  This could take a while...
Restored byebug-8.2.4
Restored coffee-rails-4.1.1
Restored coffee-script-2.4.1
Restored coffee-script-source-1.10.0
Restored concurrent-ruby-1.0.1
Restored concurrent-ruby-1.0.0
Building native extensions.  This could take a while...
Restored debug_inspector-0.0.2
Restored erubis-2.7.0
Restored execjs-2.6.0
Restored globalid-0.3.6
Restored i18n-0.7.0
Skipped io-console-0.4.2, it is a default gem
Restored jbuilder-2.4.1
Restored jquery-rails-4.1.1
Building native extensions.  This could take a while...
Restored json-1.8.3
Skipped json-1.7.7, it is a default gem
Building native extensions with: '--ignore-dependencies --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.Internal.sdk/usr/include/libxml2 --with-xml2-lib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.Internal.sdk/usr/lib --with-xslt-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.Internal.sdk/usr/include --with-xslt-lib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.Internal.sdk/usr/lib'
This could take a while...
ERROR:  While executing gem ... (Errno::ENOENT)
    No such file or directory - /Library/Ruby/Gems/2.0.0/gems/libxml-ruby-2.6.0/ext/libxml/gem_make.out

Yosemiteが悪いの...?
libxml-ruby-2.6.0って何...?

libxml-rubyとは

Libxml-ruby's primary advantage over REXML is performance - if speed is your need, these are good libraries to consider, as demonstrated by the informal benchmark below.
libxml-ruby | RubyGems.org | your community gem host

パフォーマンスを上げてくれるらしいが、こいつがいなくてエラーらしい

これは....
macでの環境構築に失敗している予感...

とりあえずrails sはできるようになったのでここはあとでなおす