Cannot run `gem install bundler` on fresh install
Issues w/ zlib on fresh install of Bazzite. Also posted it in a homebrew on linux discussion as I'm not 100% sure what's going wrong.
Lmk if y'all need I can try a few different distros to help narrow down if it's linux-wide/atomic/bazzite-specific etc.
Steps to reproduce the behavior
On Bazzite
brew install zlib rbenv
rbenv init
rbenv install 3.2.2
gem install bundler
Expected vs. actual behavior
expected it to install bundler. Got /.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in require': cannot load such file -- zlib (LoadError)` instead.
Logs
<internal:/var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- zlib (LoadError)
from <internal:/var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/util.rb:48:in `inflate'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/source.rb:147:in `fetch_spec'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/resolver/api_specification.rb:92:in `spec'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/resolver/installer_set.rb:98:in `add_always_install'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/dependency_installer.rb:322:in `resolve_dependencies'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/commands/install_command.rb:205:in `install_gem'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/commands/install_command.rb:230:in `block in install_gems'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/commands/install_command.rb:223:in `each'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/commands/install_command.rb:223:in `install_gems'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/commands/install_command.rb:169:in `execute'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/command.rb:327:in `invoke_with_build_args'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/command_manager.rb:252:in `invoke_command'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/command_manager.rb:192:in `process_args'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/command_manager.rb:150:in `run'
from /var/home/user_name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/gem_runner.rb:51:in `run'
from /home/user_name/.rbenv/versions/3.2.2/bin/gem:10:in `<main>'
Hi, I'm not familiar with Bazzite, but you should know that even if you do brew install zlib, ruby-build is not going to use that to explicitly link Ruby to it the way it does with openssl, libyaml, and readline. On most other platforms, the system zlib is auto-discovered by Ruby's build system itself (without having to do anything special for that), but this might not be true for Bazzite.
In cases where a system library wasn't found by Ruby, you can use "configure" flags to explicitly point it to a location where you've installed it. For example, this could work:
rbenv install 3.2.2 -- --with-zlib-dir="$(brew --prefix zlib)"
Awesome, that worked. Thanks a bunch!
Same problem observed on Ubuntu 22.04 WSL2. Fixed with above - thank you!