0

I'm tryng to install rails with gem install rails but when I try that I get

ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

So I tried using sudo gem install rails and I get

ERROR:  Error installing rails:
ERROR: Failed to build gem native extension.

I've checked on the internet and it says I should install RVM but when I try to do that it tells me :

Error running './configure --prefix=/Users/manhattan/.rvm/rubies/ruby-2.7.0 --with-opt-dir=/usr/local/opt/libyaml:/usr/local/opt/libksba:/usr/local/opt/readline:/usr/local/opt/zlib:/usr/local/opt/openssl@1.1 --disable-install-doc --enable-shared', please read /Users/manhattan/.rvm/log/1589107425_ruby-2.7.0/configure.log There has been an error while running configure. Halting the installation.

Could someone help me please.

  • Hey Harry, seems like you don't have the right permission the folders. Can you take a look at this answer and see if it helps you. https://stackoverflow.com/a/11644182/702436 – Hass May 10 '20 at 11:24
  • I'm sorry I just followed the it said we had to put our group. But what exactly is the group you are talking about ? – potter harry May 11 '20 at 10:40

2 Answers2

1

Installing Ruby gems (like Rails) on a Mac is a common source of confusion and frustration. Unfortunately, most solutions are incomplete, outdated, and provide bad advice. You should never need to use sudo or change permissions.

I wrote an article explaining why you should never use sudo to install gems.

This write permissions error is very common, and is due to trying to install Rails using the system Ruby (the version of Ruby that came preinstalled on your Mac). Learn why you shouldn't use the system Ruby to install gems on a Mac.

There are many questions on Stack Overflow about this permissions error, and the solution is the same. So, instead of repeating myself, I'll just link to my popular answer (480+ votes) here: https://stackoverflow.com/a/54873916/928191

monfresh
  • 7,974
  • 1
  • 25
  • 22
0

you can change the permission of the directory you are working on

# chmod -R 777 DIR_NAME
# cd DIR_NAME
# gem install rails