DEV Community

Cover image for [Fix] Issue while Installing Ruby with Rbenv in M1 Mac
Prabin Poudel for Truemark Technology

Posted on • Originally published at prabinpoudel.com.np

[Fix] Issue while Installing Ruby with Rbenv in M1 Mac

When installing Ruby with Rbenv in M1 Mac, it throws Build Failed error with message Inspect or clean up the working tree error... Let's look at how we can resolve the error and install the Ruby with Rbenv in our M1 Mac.

Error Message

Let's reproduce the error first:

  1. Install ruby with rbenv

    
      $ rbenv install 2.7.2
    
    
  2. Install error

    You will get the following error message

  - BUILD FAILED (macOS 11.2.3 using ruby-build 20210309)
  - Inspect or clean up the working tree at `/var/folders/.....`
Enter fullscreen mode Exit fullscreen mode

Ruby installation error message

NOTE: In my M1 Mac, I tried installing various ruby versions with rbenv like 2.5.0, 2.6.0, 2.7.0, 2.7.1, 2.7.2 and always ran into this same issue.

Fix

Instead of running the normal ruby install command with rbenv, let's prepend it with RUBY_CFLAGS="-Wno-error=implicit-function-declaration", which will supress all error and warnings and let the ruby installation complete.

$ RUBY_CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.5.0
Enter fullscreen mode Exit fullscreen mode

Conclusion

Tada! See the magic? Ruby should install without any issue now.

Are you using any another method to fix the issue? Let us know in the comments below.

Thank you for reading!

References

Image Credits:

Cover Image by Joshua Fuller from Unsplash

Latest comments (10)

Collapse
 
jayshii profile image
Jayprakash Datani

Thanks bro

Collapse
 
wdiazplus profile image
Wilmer Díaz

Thanks Bro. 🤖

Collapse
 
coolprobn profile image
Prabin Poudel

🙌

Collapse
 
lekastillo profile image
Luis Castillo

🙌 thanks bro

Collapse
 
coolprobn profile image
Prabin Poudel

🙏🙌

Collapse
 
calebschoepp profile image
Caleb Schoepp

Amazing! You saved my day too :D

Collapse
 
wdiazplus profile image
Wilmer Díaz

x2

Collapse
 
coolprobn profile image
Prabin Poudel

Yes 🙌 💪

Collapse
 
misraelson profile image
Matthew Israelson

Thanks, you saved my day 🙌

Collapse
 
coolprobn profile image
Prabin Poudel

Glad to hear that Matthew.

This is the reason I write blogs.