在 Mac 下搭建jekyll环境

之所以不用docker跑,是因为我目前本地环境很少用于大型开发,docker都比较占用系统资源,不想开着它。

首先使用homebrew安装chruby:

brew install chruby ruby-install xz

image-20230818174743688

安装 ruby:

ruby-install ruby 3.1.3

image-20230818174806883

如果本地无法连接到GitHub:

>>> Updating ruby versions ...
!!! Failed to download https://raw.githubusercontent.com/postmodern/ruby-versions/master/ruby/versions.txt to /Users/kelu/.cache/ruby-install/ruby/versions.txt!
!!! Failed to download ruby versions!

那个增加一下终端的代理(根据本地代理进行配置):

export HTTP_PROXY=http://127.0.0.1:1234
export HTTPS_PROXY=http://127.0.0.1:1234

等的比较久:

image-20230818175059111

设置一些环境变量:

echo "source $(brew --prefix)/opt/chruby/share/chruby/chruby.sh" >> ~/.zshrc
echo "source $(brew --prefix)/opt/chruby/share/chruby/auto.sh" >> ~/.zshrc
echo "chruby ruby-3.1.3" >> ~/.zshrc # run 'chruby' to see actual version

如果使用的是bash的话就把 .zshrc改成 .bashrc

注意⚠️,这里需要这么配置,否则运行下面一个命令就会报错:

ERROR: While executing gem … (Gem::FilePermissionError) You don’t have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

安装Jekyll

gem install jekyll

安装一些插件:

gem install jekyll-paginate

运行:

jekyll serve

参考资料


使用 lsix 让 Linux 命令行显示图片 在Mac上定时强制终止应用(微信)