Jekyll on Mac could not read file and invalid date error using bundle exec Jekyll serve

Error: could not read file /Users/min2bro/Documents/personal//jeklyll/bundle/ruby/3.1.0/gems/jekyll-4.2.2/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb: Invalid date ‘<%= Time.now.strftime(’%Y-%m-%d %H:%M:%S %z’) %>‘: Document ‘jeklyll/bundle/ruby/3.1.0/gems/jekyll-4.2.2/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb’ does not have a valid date in the YAML front matter.
ERROR: YOUR SITE COULD NOT BE BUILT:
------------------------------------
Invalid date ‘<%= Time.now.strftime(’%Y-%m-%d %H:%M:%S %z’) %>': Document ‘jeklyll/bundle/ruby/3.1.0/gems/jekyll-4.2.2/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb’ does not have a valid date in the YAML front matter.
------------------------------------------------
Jekyll 4.2.2 Please append --trace to the serve command
for any additional information or backtrace.

have you tried using an actual date in the filename? posts are required to start with the date.

Yes all my posts(md files) start with dates.

is that the actual date on that file? the error says it is not a valid date which makes sense.

That file is not available anywhere in my project folder, Not sure why it’s referring to that file in error statement.

This file is the source of your error.
Ideally Jekyll 4.x will ignore the vendor/* directories automatically. But it looks like your local Bundler configuration is to save into /jeklyll/bundle/ruby instead.

Regardless, please tell us what the output is when you run bundle config get path.

Here is the path I see after running bundle config get path:

Set for the current user (/Users/min2bro/.bundle/config): “jekyll/bundle”

You need to add the above to your Jekyll config file under the exclude key:

# _config.yml

exclude:
- "jeklyll/bundle"

P.S.: You spelt Jekyll wrong. Irrespective of whether you correct the spelling, you should always configure Jekyll to “exclude” the directory from being read. Alternatively, for future projects, use the popular vendor/bundle instead. It is automatically excluded by Jekyll 4.x

3 Likes