Hello, I am attempting to install a series of rubygems from https://rubygems.org into the snapcraft installation directory, along with any additional stage-packages, so the whole installation can be distributed as a snap image. I am using the ruby
snap in build-snaps
and stage-snaps
, instead of the ruby
plugin (due to the plugin requiring core18
which is quite old).
I first tried gem install --install-dir "${SNAPCRAFT_PART_INSTALL}" ...
to install the gems, but got a RubyGems were not loaded error.
which prevented gem install
from working.
2024-04-20T05:36:15.1792564Z + gem install --install-dir /root/parts/ronin/install ronin -v 2.0.5
2024-04-20T05:36:15.3213140Z `RubyGems' were not loaded.
2024-04-20T05:36:15.3213843Z `error_highlight' was not loaded.
2024-04-20T05:36:15.3214589Z `did_you_mean' was not loaded.
2024-04-20T05:36:15.3218625Z `syntax_suggest' was not loaded.
2024-04-20T05:36:15.3224475Z /root/parts/ronin/install/bin/gem:8:in `require': cannot load such file -- rubygems (LoadError)
2024-04-20T05:36:15.3225298Z from /root/parts/ronin/install/bin/gem:8:in `<main>'
2024-04-20T05:36:15.4788374Z Failed to run 'override-build': Exit code was 1.
I then tried overriding the GEM_HOME
environment variable using build-environment
, but received the same error:
2024-04-20T06:30:58.0302979Z + gem install ronin -v 2.0.5
2024-04-20T06:30:58.1718930Z `RubyGems' were not loaded.
2024-04-20T06:30:58.1719817Z `error_highlight' was not loaded.
2024-04-20T06:30:58.1722420Z `did_you_mean' was not loaded.
2024-04-20T06:30:58.1725681Z `syntax_suggest' was not loaded.
2024-04-20T06:30:58.1732254Z /root/parts/ronin/install/bin/gem:8:in `require': cannot load such file -- rubygems (LoadError)
2024-04-20T06:30:58.1733250Z from /root/parts/ronin/install/bin/gem:8:in `<main>'
2024-04-20T06:30:58.3301001Z Failed to run 'override-build': Exit code was 1.
I then finally tried to use bundler package --path "${SNAPCRAFT_PART_INSTALL}"
with a simple Gemfile
containing the gem I wanted to install, but got the same error!
2024-04-21T01:41:44.5765025Z + bundle package --path /root/parts/ronin/install
2024-04-21T01:41:44.9113630Z `RubyGems' were not loaded.
2024-04-21T01:41:44.9114554Z `error_highlight' was not loaded.
2024-04-21T01:41:44.9115564Z `did_you_mean' was not loaded.
2024-04-21T01:41:44.9116113Z `syntax_suggest' was not loaded.
2024-04-21T01:41:44.9220890Z /root/parts/ronin/install/bin/bundle:9:in `require': cannot load such file -- rubygems (LoadError)
2024-04-21T01:41:44.9222119Z from /root/parts/ronin/install/bin/bundle:9:in `<main>'
2024-04-21T01:41:45.0766368Z Failed to run 'override-build': Exit code was 1.
What is odd is that bundle package --path test_install/
works locally with ruby 3.2.2 and bundler 2.4.20.
What is the correct way to package an installed rubygem (with executables) as a snap? Link to the snap repo here. Thanks in advance.