potter harry
potter harry

Reputation: 1

Trying to install ruby on rails

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/[email protected] --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.

Upvotes: 0

Views: 540

Answers (2)

monfresh
monfresh

Reputation: 8056

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

Upvotes: 1

Muhammad Elbadawy
Muhammad Elbadawy

Reputation: 341

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

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

Upvotes: 0

Related Questions