6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Bashの起動が遅い時の雑な調査法

Last updated at Posted at 2019-07-11

ある時、ふと気がつくと

ターミナルを起動した時、プロンプトが表示されるまで、5秒ぐらいかかる

ようになっていました。

~/.bashrc に何か重い処理があるせいだと思いますが、具体的にどの処理なのかは見当がつきません。

調べ方

-x オプションをつけて新しいBashを起動しましょう。

$ /bin/bash -x

すると、/etc/profile .bash_profile .bashrc などの読み込み処理が、出力されます。

+ source /etc/profile
++ '[' -x /usr/libexec/path_helper ']'
+++ /usr/libexec/path_helper -s
++ eval 'PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/munki:/opt/X11/bin:/Users/foo-bar/.quarry/bin:/Users/foo-bar/.rbenv/shims:/Users/foo-bar/Documents/pungi/apps/ansible/bin:/Users/foo-bar/Documents/pungi/apps/httpie/bin:/Users/foo-bar/.pyenv/shims:/Users/foo-bar/.pyenv/bin:/usr/local/heroku/bin:/Users/foo-bar/dotfiles/bin:/Users/foo-bar/bin:/Users/foo-bar/.cabal/bin:/Users/foo-bar/.local/bin:/Users/foo-bar/node_modules/bin:/Applications/Visual' Studio 'Code.app/Contents/Resources/app/bin/:/usr/local/share/git-core/contrib/diff-highlight:/usr/share/doc/git/contrib/diff-highlight:/Users/foo-bar/.git-hooker/bin:/usr/local/go/bin:/Users/foo-bar/gocode/bin:/Users/foo-bar/node_modules/.bin:/Users/foo-bar/instantclient_11_2/:/usr/local/Cellar/terminal-notifier/2.0.0/bin/:/Users/foo-bar/xsvutils/bin:/Users/foo-bar/.gem/ruby/2.3.0/bin:/Users/foo-bar/.rbenv/bin:/Applications/MacVim.app/Contents/MacOS:/usr/local/haskell/ghc-7.8.3-x86_64/bin/:~/Documents/m3kit/bin";' export 'PATH;'
+++ PATH='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/munki:/opt/X11/bin:/Users/foo-bar/.quarry/bin:/Users/foo-bar/.rbenv/shims:/Users/foo-bar/Documents/pungi/apps/ansible/bin:/Users/foo-bar/Documents/pungi/apps/httpie/bin:/Users/foo-bar/.pyenv/shims:/Users/foo-bar/.pyenv/bin:/usr/local/heroku/bin:/Users/foo-bar/dotfiles/bin:/Users/foo-bar/bin:/Users/foo-bar/.cabal/bin:/Users/foo-bar/.local/bin:/Users/foo-bar/node_modules/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin/:/usr/local/share/git-core/contrib/diff-highlight:/usr/share/doc/git/contrib/diff-highlight:/Users/foo-bar/.git-hooker/bin:/usr/local/go/bin:/Users/foo-bar/gocode/bin:/Users/foo-bar/node_modules/.bin:/Users/foo-bar/instantclient_11_2/:/usr/local/Cellar/terminal-notifier/2.0.0/bin/:/Users/foo-bar/xsvutils/bin:/Users/foo-bar/.gem/ruby/2.3.0/bin:/Users/foo-bar/.rbenv/bin:/Applications/MacVim.app/Contents/MacOS:/usr/local/haskell/ghc-7.8.3-x86_64/bin/:~/Documents/m3kit/bin'
(以下、すごい量のログが出てくる)

途中で時間がかかっているコマンドがあるかもしれません。それを潰しましょう!!

私の場合は brew --prefix を何度も実行しているのが原因でした。

6
3
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
6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?