Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 2

How to cache Ruby gems with native extensions in container-based job?

I have this workflow which is based on this Docker image (Dockerfile). I'm trying to figure out how to do caching for the Ruby gems.

 

gh-actions.png

 

As you can see from my Actions screenshot above, some Ruby gems didn't respect the Bundler cache environment variables and always trying to install the gems (see lines with Installing prefix at line 523 & 524). They are gems with native extensions.

 

Gems without the native extensions were loaded fine from the cache (see lines with Using prefix).

 

In contrast, I didn't get this issue when using VM-based job. See this screenshot:

 

gh-actions-2.png

 

As you can see from VM-based job above, the bcrypt gem (line 51) was loaded from the cache. This is what I want in my container-based job but I'm stucked to move forward.

 

What I did wrong here? What should I change on my workflow or Dockerfile to make sure all gems are installed and loaded from the cache, regardless they are or are not native extension gems.

1 Reply
Highlighted
GitHub Partner
Message 2 of 2

Re: How to cache Ruby gems with native extensions in container-based job?

I forked your repo to my account, I run the job with container workflow two times, the first one shows Cache saved successfully  . In the second time I run the workflow, it shows that all gems are from cache. Include those with native extensions.

cache.png

Please check your logs . Have you saved bcrypt ,nio4r into your cache before using it ?