Almost broke Gentoo

I have a laptop that I dual-boot Windows 8.1, which I use for video games and a few Windows things, and an install of Gentoo for development and everthing else. Since everything in Gentoo is installed via building from source through an application called Portage, creating my Gentoo install has a great learning experience, but also very long. I had not used Gentoo for awhile because I was in Korea and wasn’t doing any development and stuck with Windows for simplicity’s sake. (I also cannot currently put my Linux side to sleep mode, so the Linux is currently less portable) When I returned, I was ready to start programming again.

Somewhere in installing an application called Scribus and removing a manual install of the programming language Rust, I lost something very important. I first noticed when I got this:

-bash: clear: command not found

I turned out that my installation of ncurses, a very important library for terminal-based applications, got removed, not only taking /lib64/libncurses.so.6 and /lib64/libncursesw.so.6, but also things like ‘clear’ and terminal configurations with it. It basically broke the system. I couldn’t use Portage to install anything nor even log in because even my terminal depended on this critical library.

At first, I tried to use my old stage3, which is a base system used during the installation of Gentoo, to replace the missing files, however, this didn’t work since I think the stage3 was using a version 5 of ncurses, while applications were linked to version 6. I think Portage, while attempting to fix some libraries just went and deleted them.

I resorted to booting to a rescue disk, which happened to be Gentoo based. However, it was out of date, and I couldn’t just add the files of the version I needed. Then I got an idea, I soft linked the location the applications were all linked to, the version 6 of ncurses, to the version 5.

libncursesw.so.6 =linked-to=> libncursesw.so.5
libncurses.so.6  =linked-to=> libncurses.so.5

Essentially, version 5 was pretending to be version 6. Thankfully, it was enough to login and run Portage.

However,the install for ncurses was giving me trouble. It kept failing, but then I noticed it seemed to be something about the 32-bit version. So I removed the 32-bit (abi_x86_32) flag from my package.use file, and did a oneshot installation of the library. It finally worked. Once I did that, I reenabled the flag, and did the install again, it finally worked. I guess the installation for 32-bit version (needed by Wine, which had 32-bit support enabled) required a command that was installed by ncurses.

After all this, I did updates, and finally got my system working again.

I am very thankful that I was able to resolve this issue without reinstalling my system, which would have taken a long time. It does show that it is important to look at what builds are failing at to identify the problem.