I install ruby follow this steps https://github.com/rbenv/rbenv on my MacBook M1 Sonoma 14.2.1. All went perfect until I need to use "gem install bundler".
terminal:
gem install bundler
ERROR: While executing gem ... (Errno::EACCES)
Permission denied @ dir_s_mkdir - /Users/pedrodiogo/.local/share/gem/specs
/usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/fileutils.rb:406:in mkdir' /usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/fileutils.rb:406:in fu_mkdir'
/usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/fileutils.rb:384:in block (2 levels) in mkdir_p' /usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/fileutils.rb:382:in reverse_each'
/usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/fileutils.rb:382:in block in mkdir_p' /usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/fileutils.rb:374:in each'
/usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/fileutils.rb:374:in mkdir_p' /usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/source.rb:151:in fetch_spec'
/usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/resolver/api_specification.rb:92:in spec' /usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/resolver/installer_set.rb:98:in add_always_install'
/usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/dependency_installer.rb:322:in resolve_dependencies' /usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/commands/install_command.rb:205:in install_gem'
/usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/commands/install_command.rb:230:in block in install_gems' /usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/commands/install_command.rb:223:in each'
/usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/commands/install_command.rb:223:in install_gems' /usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/commands/install_command.rb:169:in execute'
/usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/command.rb:327:in invoke_with_build_args' /usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/command_manager.rb:252:in invoke_command'
/usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/command_manager.rb:192:in process_args' /usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/command_manager.rb:150:in run'
/usr/local/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/gem_runner.rb:51:in run' /usr/local/var/rbenv/versions/3.2.2/bin/gem:10:in
terminal:
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.4.10
- RUBY VERSION: 3.2.2 (2023-03-30 patchlevel 53) [arm64-darwin23]
- INSTALLATION DIRECTORY: /usr/local/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0
- USER INSTALLATION DIRECTORY: /Users/pedrodiogo/.local/share/gem/ruby/3.2.0
- RUBY EXECUTABLE: /usr/local/var/rbenv/versions/3.2.2/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /usr/local/var/rbenv/versions/3.2.2/bin
- SPEC CACHE DIRECTORY: /Users/pedrodiogo/.local/share/gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/var/rbenv/versions/3.2.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- arm64-darwin-23
- GEM PATHS:
- /usr/local/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0
- /Users/pedrodiogo/.local/share/gem/ruby/3.2.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => true
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/var/rbenv/versions/3.2.2/bin
- /opt/homebrew/Cellar/rbenv/1.2.0/libexec
- /usr/local/var/rbenv/shims
- /opt/homebrew/bin
- /opt/homebrew/sbin
- /Library/Frameworks/Python.framework/Versions/3.12/bin
- /usr/local/bin
- /System/Cryptexes/App/usr/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin
- /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin
- /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
terminal:
gem env home
/usr/local/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0
And one more question, I need to install rails should I use the "sudo" command or not? Could you help me? thank you in advance!
I try to fix this looking online but I couldn't. I try change the permissions, I try to reinstall brew and nothing work.
Take a look at the ownership of your directory there, probably you did something with sudo
that you shouldn't have and that directory is owned by root
and not your own user. Probably you need to do a sudo chown -R $USER /Users/pedrodiogo/.local