Post

Fix sass-embedded error

Fix sass-embedded error

I got the following error when installing Jekyll on a new machine, had ran bundle install:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Installing sass-embedded 1.98.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/paul/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/sass-embedded-1.98.0/ext/sass

/home/paul/.rbenv/versions/3.1.2/bin/ruby -I/home/paul/.rbenv/versions/3.1.2/lib/ruby/3.1.0 -rrubygems
/home/paul/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rake-13.3.1/exe/rake

RUBYARCHDIR\=/home/paul/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/sass-embedded-1.98.0
RUBYLIBDIR\=/home/paul/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/sass-embedded-1.98.0

gem install --force --install-dir /home/paul/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/sass-embedded-1.98.0/sass/ruby
--no-document --ignore-dependencies --platform x86_64-linux-gnu --version 1.98.0 sass-embedded

rake aborted!

Had a look a few things, hadn’t touched the blog code so was sure what dependency was causing an issue. Thought why not let Gemini fix it, so I did. Note: google will have taken a copy of the code for its own training, I’m alright with that.

TLD: pin sass-embedded to 1.70.0 (while not a perfect workaround due to running ruby 3.1.2 for jekyll)

Here is the conversation, I’ve truncated details since it gets boring, but wanted to add add in-case someone found it useful.

Note: this looks to have worked but as with anything generated by AI, you need to review and take what it says with a hint of scepticism


USER 🧑‍💻

This is the Gemini CLI. We are setting up the context for our chat.

Today’s date is Friday, 13 March 2026 (formatted according to the user’s locale).

My operating system is: linux


USER 🧑‍💻

bundle install fails, explain the issue


MODEL ✨

I will start by examining the Gemfile and attempting to run bundle install to identify the cause of the failure.


MODEL ✨

The bundle install command is failing due to a NameError: uninitialized constant JSON::Fragment while installing the sass-embedded (1.98.0) gem. This suggests a compatibility issue between sass-embedded and the current Ruby or json gem environment. I will now examine the jekyll-theme-chirpy.gemspec file to review its dependencies and better understand the conflict.


MODEL ✨

I’ll start by checking if a Gemfile.lock exists but was hidden, then I’ll attempt to manually install sass-embedded (1.98.0) to see if the error persists.


MODEL ✨

I’ll verify if JSON::Fragment exists in the 2.6.1 default json gem by running ruby -e 'require "json"; p JSON::VERSION; p JSON.const_defined?(:Fragment)'.


MODEL ✨

It’s true in 2.19.1, but I suspect a bug in the newly released sass-embedded 1.98.0 might be causing the failure. Since I don’t have a Gemfile.lock, it’s resolving to the latest version. I’ll temporarily pin sass-embedded to ~> 1.97.0 in the Gemfile to see if that resolves the issue.

MODEL ✨

I’ll retry the bundle install command now.


MODEL ✨

The failure persists even with 1.97.3, suggesting an environmental issue rather than a specific gem bug. The NameError: uninitialized constant JSON::Fragment from rake during the gem install phase is suspicious, especially with google-protobuf 4.x present. I’ll attempt to install sass-embedded version 1.97.3 directly via gem install to see if it bypasses the Bundler-related error.


MODEL ✨

The gem install failure while building sass-embedded points to a possible conflict with google-protobuf 4.x, specifically the NameError: uninitialized constant JSON::Fragment which has been reported in that context. Since jekyll 4.4.1 depends on sass-embedded via jekyll-sass-converter, and sass-embedded itself uses google-protobuf, I’ll try pinning google-protobuf to ~> 3.0 in the Gemfile to see if it resolves the build issue.


MODEL ✨

I’ll run bundle install again to see if pinning google-protobuf to ~> 3.0 resolves the issue.


MODEL ✨

I’ll re-run bundle install to see the actual error message, as it could be a version conflict with the pinned google-protobuf.


MODEL ✨

Exit code 6 is unexpected; I’ll check sass-embedded 1.97.3’s google-protobuf dependency version using gem specification sass-embedded -v 1.97.3 to see if there’s a conflict with my pin, since jekyll 4.3+ and its dependencies likely have specific requirements.


MODEL ✨

Right, gem specification only works for installed gems. I’ll use gem dependency sass-embedded -v 1.97.3 --remote instead.


MODEL ✨

sass-embedded requires google-protobuf (~> 4.31), so my pin to ~> 3.0 won’t work. The NameError: uninitialized constant JSON::Fragment is likely related to google-protobuf 4.x’s json gem usage. I’ll check sass-embedded version 1.70.0’s dependencies to see if it uses an older google-protobuf that avoids this issue.


MODEL ✨

Right, sass-embedded 1.70.0 uses google-protobuf (~> 3.25), so I’ll pin sass-embedded to 1.70.0 in the Gemfile and let Bundler handle the google-protobuf resolution.


MODEL ✨

I’ll run bundle install again.


MODEL ✨

bundle install succeeded after I pinned sass-embedded to 1.70.0. The root cause was that newer sass-embedded versions require google-protobuf 4.x, which triggers a NameError: uninitialized constant JSON::Fragment in this Ruby 3.1.2 environment. Downgrading to 1.70.0 uses google-protobuf 3.x and bypasses the error. I’ll now run bundle exec jekyll build to ensure Jekyll is fully functional with this version before explaining the situation to the user.


MODEL ✨

Jekyll build worked perfectly. The issue is that the latest sass-embedded (v1.97+) requires google-protobuf v4+, which in turn needs JSON::Fragment from json >= 2.10.0. During the sass-embedded build, Ruby 3.1.2’s default json 2.6.1 is used instead of the installed 2.19.1, causing a NameError. Pinning sass-embedded to 1.70.0 uses google-protobuf 3.x and avoids this dependency. I’ll revert my Gemfile changes and provide this explanation, noting the workaround.


MODEL ✨

I’ll now explain that the bundle install failure is caused by a NameError: uninitialized constant JSON::Fragment while installing the latest sass-embedded (v1.98.0). This version requires google-protobuf (v4+), which in turn depends on features added in json v2.10.0+. Since Ruby 3.1.2 defaults to json v2.6.1, the sass-embedded build process fails when it picks up that older version instead of the installed 2.19.1. To fix this, you can pin sass-embedded to 1.70.0 in your Gemfile, as it uses google-protobuf 3.x and avoids the issue, or try upgrading your global rubygems and json gems.

The bundle install fails because the latest version of sass-embedded (1.98.0) depends on google-protobuf 4.x, which requires JSON::Fragment, a constant introduced in the json gem version 2.10.0.

In your environment (Ruby 3.1.2), the default json gem version is 2.6.1. Even though json 2.19.1 is installed, the native extension build process for sass-embedded appears to be picking up the default gem version, leading to a NameError: uninitialized constant JSON::Fragment during the build phase.

Workaround

You can resolve this by pinning sass-embedded to version 1.70.0, which depends on google-protobuf 3.x and does not have this requirement:

1
2
# Gemfile
gem "sass-embedded", "1.70.0"

I verified that Jekyll builds correctly with this version pinned. Would you like me to apply this change to your Gemfile permanently?


MODEL ✨

I will now permanently apply the sass-embedded pin to your Gemfile and run bundle install to synchronize your environment.


MODEL ✨

The Gemfile has been updated and bundle install is now completing successfully. I’ve pinned sass-embedded to version 1.70.0 to avoid the build failure caused by incompatibility with google-protobuf 4.x in your current Ruby environment.

This post is licensed under CC BY 4.0 by the author.