LoginSignup
10
5

More than 3 years have passed since last update.

[Rails]zshにしたらgemが入らなくなった

Last updated at Posted at 2018-03-05

「そのターミナル、かっこよくね!?」

先日、他の社員のパソコンを除いていたら思わず出てしまった言葉。自分のターミナルとは違って格段にかっこよくて高機能なターミナルの画面がそこには広がっていた。

「え、俺もかっこよくしたい!」

この一言が、自分の半日を潰してしまうとは思わなかった、その時は…

※この記事には間違った記述が載っている可能性もあります。

ターミナルをかっこよくしたい!

自分のターミナルの画面

  • 白地に黒のデフォルトの画面
  • なぜかパソコンの名前が何回も表示されている
    • 僕の場合はkouchair

かっこよくなった後のターミナル

  • ブランチ名が表示されている
  • 変換機能が充実!

具体的には…

  • この記事を参考にさせていただきました。
  • シェルをデフォルトのbashからzshに変更
    • ここら辺のことも完全には理解してないのでいずれ記事に書きたい。
  • ターミナルのテーマとしてicebergというテーマをインストールして外観を綺麗に
  • Preztoというフレームワークを入れて、pureというプロンプトを使用
  • これで死ぬほどターミナルがキレイになりました!
  • 基本的には上記の記事に従っただけ

rails sが効かないんですけど…

 どうやらzshにしたらbundle installをもう一度やらないといけないらしい。

$ bundle install
Fetching gem metadata from https://rubygems.org/..............
Using rake 12.3.0
Using CFPropertyList 2.3.6
Using concurrent-ruby 1.0.5
Using i18n 0.9.1
Using minitest 5.11.1
Using thread_safe 0.3.6
Using tzinfo 1.2.4
Using activesupport 5.0.6
Using builder 3.2.3
Using erubis 2.7.0
Using mini_portile2 2.3.0
Fetching nokogiri 1.8.1
Installing nokogiri 1.8.1 with native extensions
Errno::EACCES: Permission denied @ rb_sysopen -
/Users/kouch/Desktop/hb-check/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.1/.autotest
An error occurred while installing nokogiri (1.8.1), and Bundler
cannot continue.
Make sure that `gem install nokogiri -v '1.8.1'` succeeds before bundling.

In Gemfile:
  octicons_helper was resolved to 4.2.0, which depends on
    rails was resolved to 5.0.6, which depends on
      actioncable was resolved to 5.0.6, which depends on
        actionpack was resolved to 5.0.6, which depends on
          actionview was resolved to 5.0.6, which depends on
            rails-dom-testing was resolved to 2.0.3, which depends on
              nokogiri

nokogiriだけまたインストールしようとすると…

$ sudo gem install nokogiri -v '1.8.1'
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.3.0/gems/nokogiri-1.8.1/ext/nokogiri
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180305-68935-xs072c.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.3.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.5.

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.5.tar.gz into tmp/x86_64-apple-darwin17/ports/libxml2/2.9.5... OK
Running 'configure' for libxml2 2.9.5... OK
Running 'compile' for libxml2 2.9.5... ERROR, review '/Library/Ruby/Gems/2.3.0/gems/nokogiri-1.8.1/ext/nokogiri/tmp/x86_64-apple-darwin17/ports/libxml2/2.9.5/compile.log' to see what happened. Last lines are:
========================================================================
  CCLD     libxml2.la
  CC       testdso.lo
  CCLD     testdso.la
  CC       xmllint.o
  CCLD     xmllint
ld: warning: ignoring file /usr/local/Cellar/xz/5.2.3/lib/liblzma.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/Cellar/xz/5.2.3/lib/liblzma.dylib
Undefined symbols for architecture i386:
  "_lzma_auto_decoder", referenced from:
      _xz_head in libxml2.a(xzlib.o)
  "_lzma_code", referenced from:
      _xz_decomp in libxml2.a(xzlib.o)
  "_lzma_end", referenced from:
      ___libxml2_xzclose in libxml2.a(xzlib.o)
  "_lzma_properties_decode", referenced from:
      _is_format_lzma in libxml2.a(xzlib.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [xmllint] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================================================================
*** 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
    --without-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=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME)
    --help
    --clean
    --use-system-libraries
    --enable-static
    --disable-static
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --enable-cross-build
    --disable-cross-build
/Library/Ruby/Gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:402:in `block in execute': Failed to complete compile task (RuntimeError)
    from /Library/Ruby/Gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in `chdir'
    from /Library/Ruby/Gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:373:in `execute'
    from /Library/Ruby/Gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:115:in `compile'
    from /Library/Ruby/Gems/2.3.0/gems/mini_portile2-2.3.0/lib/mini_portile2/mini_portile.rb:154:in `cook'
    from extconf.rb:365:in `block (2 levels) in process_recipe'
    from extconf.rb:257:in `block in chdir_for_build'
    from extconf.rb:256:in `chdir'
    from extconf.rb:256:in `chdir_for_build'
    from extconf.rb:364:in `block in process_recipe'
    from extconf.rb:262:in `tap'
    from extconf.rb:262:in `process_recipe'
    from extconf.rb:548:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/nokogiri-1.8.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/nokogiri-1.8.1 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/nokogiri-1.8.1/gem_make.out


これを叩いても怒濤のエラーが吐き出された。意味わからん。書いてある指示に従ってもうまく行かず。

試行錯誤した結果

理由はrubyのバージョンのせいだった。
zshに変更したので今までのrubyの2.4.1ではなく、rubyの2.3.3を参照していた。(パスのせい??)
bundle installはrubyのversionに対してgemをインストールするので、古いversionのrubyにインストールしていても仕方ない、ということだ。
という事でrubyのversionを2.4.1に戻す!

$ echo 'eval "$(rbenv init -)"' >> ~/.zshrc
$ source ~/.zshrc

これでもう一度$ bundle installする。うまくいきました。

 まとめ

環境設定でハマると地獄。
根本的にいろんなことを理解していないといけない。shellとはbundleとか今度ちゃんと勉強したい。

10
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
5