jekyll部署 (windows 10)

windows本地部署 jekyll

  • 搭建git pages过程中,发现github编译失败之后处理很麻烦(多次push),于是打算本地搭建一个能编译检查的jekyll
  • warning:本地部署jekyll很麻烦,慎重。
配置Jekyll 参考:

git pages配置:https://zhuanlan.zhihu.com/p/51240503
本地部署jekyl:https://zhuanlan.zhihu.com/p/139567128
jekyll official: https://jekyllrb.com/docs/installation/windows/

执行过程

1 安装Ruby

installer选默认配置,C盘爆的自己改一下安装路径
最后弹出来一个cmd,猜测对应official中的"ridk install step on the last stage of the installation wizard",自己选123安装下述3之1(我选的1)
1 - MSYS2 base installation
2 - MSYS2 system update (optional)
3 - MSYS2 and MINGW development toolchain>(

2 ruby -v和 gem -v 查看版本 # done

3 安装 Jekyll: install Jekyll and Bundler using
gem install jekyll, gem install bundler

jekyll 报错

问题:

  • 安装完,jekyll -v 是正常的;但是一进gitbook仓库就jekyll无法执行。
in `encode': "\\xA3" on UTF-8 (Encoding::InvalidByteSequenceError)
        from G:/data/Ruby31-x64/lib/ruby/3.1.0/pathname.rb:52:in `chop_basename'
        from G:/data/Ruby31-x64/lib/ruby/3.1.0/pathname.rb:378:in `plus'
        from G:/data/Ruby31-x64/lib/ruby/3.1.0/pathname.rb:358:in `+'
        from G:/data/Ruby31-x64/lib/ruby/3.1.0/pathname.rb:424:in `join'
        from G:/data/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.4.9/lib/bundler/settings.rb:439:in `global_config_file'
修复

直接原因:%USERFROFILE%是中文,因此初始化global_config_file时失败了
找到 G:/data/Ruby31-x64/lib/ruby/3.1.0/pathname.rb:52
添加编码转换

 
#### interpolate ####
 begin
   base = base.encode('utf-8', 'gb2312')
   path = path.encode('utf-8', 'gb2312')
 rescue
   base = base
   path = path
 end
 #### #### ####

 if /\A#{SEPARATOR_PAT}?\z/o.match?(base)
   return nil
 else
   return path[0, path.rindex(base)], base
 end
jekyll -v, jekyll server
  • 直接原因修好了,还是无法执行;
  • 根本原因:路径下存在一个Gemfile,jekyll会自动读取其中的内容执行
    (罪魁祸首↓)
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
gem "jekyll"
gem 'jekyll-feed'
gem 'jekyll-readme-index'
gem 'jemoji'
gem 'webrick'

# gem "rails"
  • 安装上述所有包
gem install jekyll-feed jekyll-readme-index ....

如果很慢应该可以搜一下 gem source换个源;如果还是很慢,把挂着的abc给关了吧😓

  • 最后执行 jekyll server(还需要开管理员权限 在cmd中执行😓 否则permission denied 真是谢谢我过去的折腾)
Mark: ruby简单语法

ruby的打印

    # puts base # 输出乱码
    # puts base.inspect # 输出\x开头的字节
    
    # puts path
    # puts base == ':)' #
    # puts path.rindex(base).inspect

ruby的空判断(空字符串)

    # puts base.nil?

ruby的错误捕捉机制:

begin

rescue

end
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值