I ran into a problem installing the latest ruby version - 2.7.0 - at the time of this writing.
I was using rbenv, so when I ran the following command on my Linux Ubuntu system:
$ rbenv install 2.7.0
I got the following console output:
Downloading ruby-2.7.0.tar.bz2... -> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.0.tar.bz2 Installing ruby-2.7.0... BUILD FAILED (Ubuntu 18.04 using ruby-build 20200115-8-g73b926b) Inspect or clean up the working tree at /tmp/ruby-build.20200210091058.6452.C1da1m Results logged to /tmp/ruby-build.20200210091058.6452.log Last 10 log lines: tool/config.guess already exists tool/config.sub already exists checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu checking for gcc... gcc checking whether the C compiler works... no configure: error: in `/tmp/ruby-build.20200210091058.6452.C1da1m/ruby-2.7.0': configure: error: C compiler cannot create executables See `config.log' for more details
My gcc was up-to date and all related libraries were installed, so this was confusing.
Turns out my problem was simply a ruby script I wrote that interfered with the gcc configurations during installation.
I wrote a ruby script called ld (list directories), that displayed a list of directories of all my projects grouped into certain environments. I did this so I could simply copy and paste the directory path so I could code in vim. I saved it under [~/bin], which was recommended for user-defined scripts.
I noticed when I tried to compile a C file, it would display the same output as the ld script. When I browsed through the config.log, in the log it gave the same output:
94 configure:4056: checking whether the C compiler works 95 configure:4078: gcc -I/home/user/.rbenv/versions/2.7.0/include -L/home/user/.rbenv/versions/2.7.0/lib conftest.c >&5 96 /home/user/.rbenv/versions/2.6.1 97 /home/user/Documents/Coding 98 /home/user/Documents/Coding/Ruby 99 /home/user/Documents/Coding/Ruby/practice 100 /home/user/Documents/Coding/Ruby/fun/Ruby-Fun 101 /home/user/Documents/Coding/Ruby/practice/the_well_grounded_rubyist/ 102 /home/user/Documents/Coding/Ruby/Rails 103 /home/useruser/Documents/Coding/Ruby/Rails/practice 104 /home/user/Documents/Coding/Ruby/Rails/work 105 /home/useruser/Documents/Coding/Rust 106 /home/user/Documents/Coding/Rust/Practice 107 configure:4082: $? = 0 108 configure:4120: result: no *Removed for brevity* 126 configure:4125: error: in `/tmp/ruby-build.20200210093603.8012.htWj9f/ruby-2.7.0': 127 configure:4127: error: C compiler cannot create executables 128 See `config.log' for more details
Line 95 tried to check whether the C compiler works. Line 96 until 106, displayed the output of my ld script. Thus I'm assuming configure resulted to a no.
I renamed my script, and all was well. I'm not sure if there was a name clash or something, but after renaming it, my problem was solved. A simple script I wrote to help me navigate my directories easily via my terminal gave me a headache for a better part of a day.
What I learned, and hopefully what you can pick up from this, is to be more vigilant and aware of decisions when configuring user-defined settings not to clash with system-defined settings. A simple solution to a simple problem.
p.s. After years of being a member, this is my first post. A getting-my-feet-wet kind of post. I finally decided to get out there and share and contribute. I hope to post more on my journey to mastering ruby.