Solution for the tilt/erubis Error Occurring on narou-docker Startup
When using narou-docker, the following error occurred during the Dockerfile build process.
internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require': cannot load such file -- tilt/erubis (LoadError)
In this article, we explain the cause of this error and the solution posted in GitHub Issue #443.
Background of the Error
Inside narou 3.9.1, tilt is used as the template engine. Traditionally, a module called tilt/erubis existed, but due to modern environments and gem updates, cases where erubi is used instead of erubis have been increasing.
This error is caused by the fact that even though narou requires tilt/erubis, the corresponding file no longer exists. Because tilt dropped support for erubis, this issue occurred upon starting narou-docker.
Solution
The solution recommended in GitHub Issue #443 is as follows.
-
Install erubi
First, install version 1.13 of the erubi gem within the Dockerfile. This makes the latest erubi available. -
Replace the Reference in the Code
In narou’s internal code (/usr/local/bundle/gems/narou-3.9.1/lib/web/appserver.rb), replace the reference totilt/erubiswithtilt/erubi. By using the sed command, the replacement process is executed automatically at build time.
A specific example of part of the Dockerfile is shown below.
We have confirmed that this configuration correctly replaces the template engine module referenced by narou and resolves the error.
Explanation and Discussion
-
Why erubi?
erubi is being developed as the successor to erubis, offering improvements in performance and security. By modifying narou’s code, we can maintain compatibility suited for modern environments. -
Using the sed Command
The key point is using the sed command inside the Dockerfile to automatically patch narou’s source code during the build. This eliminates the hassle of manual fixes or applying patches. -
Future Outlook
Since this matter has also been discussed in GitHub Issue #443 and the fix has been merged into the develop branch, it is expected to be officially supported in future updates. It is recommended to check for project update information regularly.
Conclusion
The tilt/erubis error that occurs during the Dockerfile build of narou-docker was caused by a compatibility issue with the latest template engine, erubi.
By following the solution posted in GitHub Issue #443 and adding the installation of erubi and the sed replacement process to the Dockerfile, we were able to work around the issue.
We hope this approach helps anyone struggling with the same error to resolve it smoothly.