DEV Community

Getulio Ruiz
Getulio Ruiz

Posted on

Ruby gem command install does not find zlib in WSL environment

Today, I encountered an issue while installing Ruby with asdf on Windows using WSL. When attempting to run gem install <extension>, I received the following error:

<internal:/home/<user>/.asdf/installs/ruby/3.3.0/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require': cannot load such file -- zlib (LoadError)
Enter fullscreen mode Exit fullscreen mode

After an extensive search, the solution that worked for me was to install the following packages:

sudo apt-get install libffi-dev libncurses-dev libbz2-dev libssl-dev libreadline-dev libsqlite3-dev zlib1g-dev
Enter fullscreen mode Exit fullscreen mode

Following this, I reinstalled the Ruby:

asdf uninstall ruby <version>
asdf install ruby <version>
Enter fullscreen mode Exit fullscreen mode

After that, I was able to execute the gem install command.

Top comments (0)