0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

M1 Mac向け:GitHub Pages Jekyll導入 & 127.0.0.1:4000 でindex.md を表示する手順

Last updated at Posted at 2025-09-22

はじめに

M1 Mac(Apple Silicon)でrubyインストールからJekyllを動かす手順をまとめました。

背景

GitHub Pagesでindex.mdをJekyllでビルドしたページを公開しようと思ったのですが、見た目確認のたびにデプロイすると時間がかかるので、ローカルでJekyllを動かして確認したいと思いました。

rubyに慣れておらず、rubyやjekyllのインストールに手間取ったので、うまくいった方法をメモします。

目指すゴールは以下です。

  • プロジェクト直下に Jekyll を入れて、index.md をローカルで確認

以下の記事が参考になりました。

環境

  • macOS (Apple Silicon/M1)
  • シェルはzsh(bashでもあまり変わらないかと)

手順

Xcode コマンドラインツール

xcode-select --install

Homebrew を Apple Silicon 版であることを確認

which brew
brew --prefix
  • /opt/homebrew が出れば Apple Silicon
  • /usr/local が出れば、Intel版です。

Intel版だった場合は以下などを参考に、Apple Silicon版に入れ替えてください。共存させる方法もあるようなので、お好みで。

Rubyのセットアップ

jekyllはRuby製のツールなので、Rubyを入れます。

rbenv

システムのRubyは古いので、rbenvで最新版を入れます。

brew install rbenv ruby-build

# シェル初期化(~/.zshrcに追記)
echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc
eval "$(rbenv init - zsh)"

rubyのアップデート

# インストール可能なバージョン一覧(長いので末尾だけ見るなら tail)
rbenv install -l | tail

# 例:安定版をインストール(3.x系など最新安定を選んでください)
rbenv install 3.4.5

# プロジェクトのデフォルトに設定
rbenv global 3.4.5

# bundler を入れる
gem install bundler

# rbenv に反映
rbenv rehash

Jekyll のセットアップ

index.mdを含むJekyllプロジェクトを作成します。

mkdir mypage
cd mypage
touch index.md

index.mdの中身に適当なマークダウンを書いておきます。

index.md
# こんにちは Jekyll!
Apple Silicon (M1) で動いています。

bundle init で Gemfile を作成し、github-pagesのJekyllを追加します。

bundle init
bundle add github-pages --group "jekyll_plugins"

依存関係のインストールとサーブを実行します。

bundle install
bundle exec jekyll serve

ブラウザで http://127.0.0.1:4000/ を開き、index.mdの内容が見えれば成功です。
必要に応じて_config.yml や _layouts/ などを追加してカスタマイズしてください。

トラブルシューティング・試行錯誤

システムのrubyの利用

最初、rbenvを使わずにシステムのrubyを使おうとしましたが、sudoを求められ、なんとなく不安だったので断念しました。

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

rbenvの導入

intel版のbrewで試したとき、rbenvのインストールまではできたのですが、その後、rbenv install 3.4.5 で以下のようなエラーが出ました。
ChatGPT曰く、intel版であることが原因で、apple silicon版に入れ替える必要があるとのことでした。

% rbenv install 3.4.5
ruby-build: using openssl@3 from homebrew
==> Downloading ruby-3.4.5.tar.gz...
-> curl -q -fL -o ruby-3.4.5.tar.gz https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.5.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22.1M  100 22.1M    0     0   9.8M      0  0:00:02  0:00:02 --:--:--  9.8M
==> Installing ruby-3.4.5...
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew
-> ./configure "--prefix=$HOME/.rbenv/versions/3.4.5" --with-openssl-dir=/usr/local/opt/openssl@3 --enable-shared --with-libyaml-dir=/usr/local/opt/libyaml --with-gmp-dir=/usr/local/opt/gmp --with-ext=openssl,psych,+
-> make -j 8
*** Following extensions are not compiled:
openssl:
	Could not be configured. It will not be installed.
	/private/var/folders/zr/rkwsn70s1vv324nlhbf4jcz80000gn/T/ruby-build.20250920201615.43973.xorM8A/ruby-3.4.5/ext/openssl/extconf.rb:116: OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed.
	Check /var/folders/zr/rkwsn70s1vv324nlhbf4jcz80000gn/T/ruby-build.20250920201615.43973.xorM8A/ruby-3.4.5/ext/openssl/mkmf.log for more details.
psych:
	Could not be configured. It will not be installed.
	Check /var/folders/zr/rkwsn70s1vv324nlhbf4jcz80000gn/T/ruby-build.20250920201615.43973.xorM8A/ruby-3.4.5/ext/psych/mkmf.log for more details.

BUILD FAILED (macOS 14.7.4 on arm64 using ruby-build 20250916.1)

You can inspect the build directory at /var/folders/zr/rkwsn70s1vv324nlhbf4jcz80000gn/T/ruby-build.20250920201615.43973.xorM8A
See the full build log at /var/folders/zr/rkwsn70s1vv324nlhbf4jcz80000gn/T/ruby-build.20250920201615.43973.log
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?