![]() ![]() In this case, you need sudo because you're altering system files that are managed by the OS. But don't do this! $ sudo gem install railsĪny time you are about to run sudo, you should stop and ask if you're about to shoot yourself in the foot. You can install gems as a superuser to override the permissions restriction. Unix-based systems are powerful, so there's a workaround. You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory ![]() If you try to install a gem, for example gem install rails, you'll get a permissions error: ERROR: While executing gem. Ordinary users are not allowed to write to it (and you really shouldn't alter this folder). That directory is owned by root, the system superuser. ![]() If you use the Mac system Ruby, running gem install will try to save gems to the system Ruby directory /Library/Ruby/Gems/2.6.0. Most Ruby projects use at least a few gems. RubyGems are the ready-made software libraries that make development easy and fun in Ruby. For a guide that compares version managers and shows the best way to install Ruby, see my article Install Ruby on a Mac.īut why not use the macOS default Ruby? Let's take a look at the reasons why it's a bad idea to use the Mac default Ruby for development. Ruby for developmentįor developing projects with Ruby, you should Install Ruby with Homebrew or use a version manager such as asdf, chruby, rbenv, or rvm.Ī version manager helps if you're juggling multiple projects and can't update all at once. It's fine to use the system Ruby for running sysadmin scripts, as long as you don't alter the system Ruby by attempting to update it or add gems.īut you don't want to use it when you are developing projects in Ruby. If you see /usr/bin/ruby, it is the pre-installed macOS system Ruby. Use the which command to see where Ruby is installed: $ which ruby MacOS comes with a "system Ruby" pre-installed. Someone may have once told you, "Don't use the system Ruby." It's good advice, but why? Let's find out. ![]()
1 Comment
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |