<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Roland L</title>
    <description>The latest articles on DEV Community by Roland L (@rolandlluka).</description>
    <link>https://dev.to/rolandlluka</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2786658%2Fa0c9e137-0845-4437-be98-863d86851399.jpeg</url>
      <title>DEV Community: Roland L</title>
      <link>https://dev.to/rolandlluka</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rolandlluka"/>
    <language>en</language>
    <item>
      <title>Fixing CircleCI Nightmares: Solving Missing JavaScript Runtime &amp; Chrome GPG Key Errors in Rails CI/CD 🚀🚀</title>
      <dc:creator>Roland L</dc:creator>
      <pubDate>Thu, 30 Jan 2025 08:39:17 +0000</pubDate>
      <link>https://dev.to/rolandlluka/fixing-circleci-nightmares-solving-missing-javascript-runtime-chrome-gpg-key-errors-in-rails-2a3g</link>
      <guid>https://dev.to/rolandlluka/fixing-circleci-nightmares-solving-missing-javascript-runtime-chrome-gpg-key-errors-in-rails-2a3g</guid>
      <description>&lt;p&gt;You know that feeling when your CI/CD pipeline is supposed to "just work"—but instead, it throws cryptic errors, and you're left scratching your head? Yeah, that was me last week.&lt;/p&gt;

&lt;p&gt;I was setting up CircleCI for a Ruby on Rails project, and everything was running smoothly… until it wasn’t. Suddenly, my test suite failed with:&lt;/p&gt;

&lt;p&gt;🚨 ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime&lt;br&gt;
🔑 GPG error: NO_PUBKEY 32EE5355A6BC6E42&lt;/p&gt;

&lt;p&gt;At first, I thought, "No big deal, just install Node and update Chrome, right?" But nope—things got messier. The default CircleCI Ruby image lacked a JavaScript runtime, Chrome needed a new GPG key, and my pipeline was stuck in failure mode.&lt;/p&gt;

&lt;p&gt;After a few hours (okay, maybe more) of debugging, I finally cracked the code. In this post, I’ll walk you through the exact problem, what didn’t work, and how I ultimately fixed my CircleCI config to make my Rails tests run smoothly again. Let’s dive in! 🔧✨&lt;/p&gt;
&lt;h2&gt;
  
  
  How I Fixed CircleCI’s Missing JavaScript Runtime &amp;amp; Chrome GPG Key Errors in My Rails Pipeline
&lt;/h2&gt;

&lt;p&gt;When setting up CircleCI for a Ruby on Rails project, I ran into two annoying issues that completely broke my pipeline:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;ExecJS couldn’t find a JavaScript runtime (because the Ruby image didn’t include Node.js).&lt;/li&gt;
&lt;li&gt;Google Chrome’s GPG key had changed, causing apt-get update to fail with a NO_PUBKEY error.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you’re dealing with a similar problem, don’t panic! I’ll walk you through how I fixed it, step by step.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Problem: My Tests Started Failing in CircleCI
&lt;/h2&gt;

&lt;p&gt;At first, my tests were running fine. But then, one day, I saw this error when running rake db:create in my CI logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime.
See https://github.com/rails/execjs for a list of available runtimes.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, while trying to install Chrome for my system tests, this lovely error showed up:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GPG error: https://dl.google.com/linux/chrome/deb stable InRelease:
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 32EE5355A6BC6E42
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without a JS runtime, Rails couldn’t compile assets. Without a valid GPG key, I couldn’t install Chrome.&lt;br&gt;
Pipeline = Dead. 🚨&lt;/p&gt;
&lt;h2&gt;
  
  
  🔎 Step 1: Switch to a Ruby Image That Includes Node.js
&lt;/h2&gt;

&lt;p&gt;Since ExecJS needs a JavaScript runtime, my first move was to use a Ruby image that comes with Node built-in. Instead of using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker:
  - image: cimg/ruby:3.1.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I switched to cimg/ruby:3.1.4-node, which includes both Ruby and Node.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker:
  - image: cimg/ruby:3.1.4-node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 Why? Because Rails uses ExecJS (via gems like autoprefixer-rails) to compile assets, and Node.js provides the runtime ExecJS expects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Fix the Google Chrome GPG Key Issue
&lt;/h2&gt;

&lt;p&gt;Google recently rotated their signing key, which broke apt-get update for Chrome installations. To fix this, I manually added the updated key before running apt-get update:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- run:
    name: Add Google Chrome public key
    command: |
      sudo apt-get update -y
      sudo apt-get install -y wget
      wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 Why? This allows apt-get to trust Google’s repo again, letting Chrome install without errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠 Step 3: Install Chrome &amp;amp; Chromedriver for System Tests
&lt;/h2&gt;

&lt;p&gt;Even though I was using the -node image (instead of -browsers), I still needed Chrome for feature/system tests. Instead of installing it manually, I used CircleCI’s browser-tools orb:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;orbs:
  browser-tools: circleci/browser-tools@1.5.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, inside my test job (run_rspec), I installed both Chrome and Chromedriver:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- browser-tools/install-chrome
- browser-tools/install-chromedriver
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 Why? This is a cleaner, more stable way to install Chrome compared to managing it manually with apt-get install google-chrome-stable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Run Tests with Everything in Place
&lt;/h2&gt;

&lt;p&gt;Once I had:&lt;br&gt;
✅ A JavaScript runtime (Node.js)&lt;br&gt;
✅ A valid GPG key for Chrome&lt;br&gt;
✅ Chrome &amp;amp; Chromedriver installed&lt;/p&gt;

&lt;p&gt;My RSpec tests could finally run without breaking:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- run:
    name: Run RSpec tests
    command: |
      TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
      bundle exec rspec --format progress \
                        --format RspecJunitFormatter \
                        --color \
                        --out tmp/rspec/test-results/rspec.xml \
                        $TEST_FILES
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🎉 Final Thoughts: No More CircleCI Headaches!&lt;/p&gt;

&lt;p&gt;✅ Switching to cimg/ruby:3.1.4-node fixed the missing JavaScript runtime issue.&lt;br&gt;
✅ Manually adding Google’s updated signing key solved the Chrome installation issue.&lt;br&gt;
✅ Using the browser-tools orb made installing Chrome &amp;amp; Chromedriver much easier.&lt;/p&gt;

&lt;p&gt;Now, my Rails CI/CD pipeline runs smoothly again, and I can actually focus on writing code instead of debugging CircleCI configs! 🚀&lt;/p&gt;

&lt;p&gt;If you’re running into the same issues, try these fixes and let me know if they work for you! 💬&lt;/p&gt;

</description>
      <category>rails</category>
      <category>circleci</category>
      <category>cicd</category>
      <category>pipelines</category>
    </item>
  </channel>
</rss>
