You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Heroku执行jekyll serve报错求助:文件已存在问题

Fixing Jekyll Serve Error on Heroku: File exists @ syserr_fail2_in - /app/_site/bin/erb

Hey there, let's get this Jekyll + Heroku issue sorted out for you! That error about the existing /app/_site/bin/erb file is happening because Jekyll is trying to copy system-level Ruby bin files (which are symlinks in Heroku's environment) into your _site directory, but those paths already exist from a prior build. Here's how to fix it:

Step 1: Exclude the bin directory from Jekyll's processing

Heroku's Ruby environment has a system bin directory that Jekyll doesn't need to include in your static site. Add bin to your _config.yml's exclude list to tell Jekyll to ignore it entirely:

# _config.yml
exclude: ['config.ru', 'Gemfile', 'Gemfile.lock', 'vendor', 'Procfile', 'Rakefile', 'bin']

Step 2: Add a clean build flag to your Procfile

To prevent leftover files from previous builds causing conflicts, add the --clean flag to your jekyll serve command. This forces Jekyll to delete the _site directory before rebuilding:

# Procfile
web: bundle exec jekyll serve --port $PORT --host 0.0.0.0 --clean

Step 3: Double-check your gitignore (optional)

If you accidentally committed a local bin directory to your repo, add bin/ to your .gitignore file (except for any custom scripts you need—Heroku handles Ruby's bin files automatically):

# .gitignore
bin/

Why this works

On your local machine, your Ruby environment's bin directory structure doesn't create this symlink conflict because Jekyll isn't trying to copy system-level symlinks into your _site folder. But Heroku's containerized environment has these symlinks, and Jekyll's static file handler tries to replicate them—leading to the "file exists" error when a prior build left those paths intact. Excluding bin and forcing a clean build eliminates this conflict entirely.

If you go back to using Puma with rack-jekyll and hit permalink issues, make sure your config.ru uses the :force_build option to ensure Jekyll generates all static files correctly before Rack serves them:

# config.ru
require 'rack/jekyll'
run Rack::Jekyll.new(:force_build => true)

This ensures Jekyll finishes building your site with proper permalinks before Puma starts serving content.

内容的提问来源于stack exchange,提问作者Clinton Shane Wright

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:37:24