jekyll 4.0.0 | Error: uninitialized constant TZInfo::Timezone

483 views Asked by At

i want to view website on a live server ..but im not familiar with jekyll yet

first i tried bundle exec jekyll serve and this is the output in atom terminal:

    PS C:\Users\user\Documents\GitHub\bioscreator-lp> bundle exec jekyll serve
    Configuration file: C:/Users/user/Documents/GitHub/bioscreator-lp/_config.yml
    Dependency Error: Yikes! It looks like you don't have tzinfo or one of its dependencies 
    installed. In order to use Jekyll as currently configured, you'll need to ins
    tall this gem. If you've run Jekyll with `bundle exec`, ensure that you have included the 
    tzinfo gem in your Gemfile as well. The full error message from Ruby is: 'can
    not load such file -- tzinfo' If you run into trouble, you can find helpful resources at 
    https://jekyllrb.com/help/!
    jekyll 4.0.0 | Error:  tzinfo
    C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-4.0.0/lib/jekyll/external.rb:73:in `rescue 
    in block in require_with_graceful_fail': tzinfo (Jekyll::Errors::MissingDepend
    encyException)

after a few research i tried to put gem 'tzinfo-data' into gemfile and run bundle install run bundle exec jekyll serve

and there still another error:

     PS C:\Users\user\Documents\GitHub\bioscreator-lp> bundle exec jekyll serve
     Configuration file: C:/Users/user/Documents/GitHub/bioscreator-lp/_config.yml
     jekyll 4.0.0 | Error:  uninitialized constant TZInfo::Timezone

    tz = TZInfo::Timezone.get(timezone)
               ^^^^^^^^^^
     C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-4.0.0/lib/jekyll/utils/win_tz.rb:16:in 
    `calculate': uninitialized constant TZInfo::Timezone (NameError)

    tz = TZInfo::Timezone.get

theres another solution i found here in stackoverflow but looks like it will only works in older version of jekyll..my version is 4.0.0

1

There are 1 answers

0
Christian On

Strange error. I know that I had similar issues in the past. Jekyll 4.2.2 is working for me. I am on Windows and this is how I set up Jekyll using WSL.

Configuration

My Gemfile (includes two different tz gems after installation)

The installation also adds the tzinfo gem with a fixed max version.

# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
# and associated library.
platforms :mingw, :x64_mingw, :mswin, :jruby do
  gem "tzinfo", "~> 1.2"
  gem "tzinfo-data"
end

I read something about a bug in the bundler gem that could be solved by removing the platforms but maybe this has been solved. The platforms should not play a role at all and you can leave it out, if you're not on Windows.

Ruby version

ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]

Installation

Installing the Jekyll gem

user@DESKTOP:/mnt/c/Users/User$ gem install jekyll
...
Fetching jekyll-4.2.2.gem
...
6 gems installed

Creating a Jekyll page

user@DESKTOP:/mnt/c/Users/User$ jekyll new testpage
Running bundle install in /mnt/c/Users/User/testpage...
  Bundler: Fetching gem metadata from https://rubygems.org/............
  Bundler: Resolving dependencies...
  ...
  Bundler: Bundle complete! 7 Gemfile dependencies, 31 gems now installed.
  Bundler: Use `bundle info [gemname]` to see where a bundled gem is installed.
New jekyll site installed in /mnt/c/Users/User/testpage.

Adding webrick to Gemfile (maybe not required for you)

user@DESKTOP:/mnt/c/Users/User$ cd testpage/
user@DESKTOP:/mnt/c/Users/User/testpage$ bundle add webrick

Starting the Jekyll server

user@DESKTOP:/mnt/c/Users/User/testpage$ jekyll s
Configuration file: /mnt/c/Users/User/testpage/_config.yml
            Source: /mnt/c/Users/User/testpage
       Destination: /mnt/c/Users/User/testpage/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
       Jekyll Feed: Generating feed for posts
                    done in 0.41 seconds.
                    Auto-regeneration may not work on some Windows versions.
                    Please see: https://github.com/Microsoft/BashOnWindows/issues/216
                    If it does not work, please upgrade Bash on Windows or run Jekyll with --no-watch.
 Auto-regeneration: enabled for '/mnt/c/Users/User/testpage'
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.