Search code examples
rubyrbenvmacos-mojave

Unable to install Ruby 2.5.1 using rbenv, gives C Compiler error


I am trying to set up a new machine and prepping the dev environment. My Xcode and command line tools are all installed. I used homebrew to install ruby-build and rbenv. I then execute the command:

rbenv install 2.5.1

However I get the following error:

BUILD FAILED (OS X 10.14.2 using ruby-build 20181225)
Inspect or clean up the working tree at /var/folders/
kk/d2c_1jqj2dd88mcscwsrcz_w0000gp/T/ruby-build.201901
18184337.15691
Results logged to /var/folders/kk/d2c_1jqj2dd88mcscws
rcz_w0000gp/T/ruby-build.20190118184337.15691.log

Last 10 log lines:
checking build system type... x86_64-apple-darwin18.2.0
checking host system type... x86_64-apple-darwin18.2.0
checking target system type... x86_64-apple-darwin18.2.0
checking whether the C compiler works… no
configure: error: in
`/var/folders/kk/d2c_1jqj2dd88mcscwsrcz_w0000gp/T/ruby
build.20190118184337.15691/ruby-2.5.1':
configure: error: C compiler cannot create executables
See `config.log' for more details
./configure: line 346: sort: No such file or directory
./configure: line 343: sed: No such file or directory
make: *** No targets specified and no makefile found.
  Stop.

I have already tried to go into the logs to see if I can see something there, but nothing.

I have tried searching for solution to this but to no avail.

I would really appreciate if someone can help point me to the right direction and help me resolve this.

Thank you!


Solution

  • What is the name of your home folder? rbenv doesn't like spaces in the home folder name. They should be replaced or removed.