While referring to the following sitegemofbyebugI tried to use, but I got an error and could not install it, so please tell me the solution.
An active engineer explains how to use Ruby debug [For beginners

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

sudoWhen I try to install it with, I get the following error.

% sudo gem install by ebug
Building native extensions. This could take a while ...
ERROR: Error installing by ebug:
    ERROR: Failed to build gem native extension.
    current directory: /Library/Ruby/Gems/2.6.0/gems/byebug-11.1.3/ext/byebug
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20210101-34152-1ajk8t8.rb extconf.rb
creating Makefile
current directory: /Library/Ruby/Gems/2.6.0/gems/byebug-11.1.3/ext/byebug
make "DESTDIR =" clean
current directory: /Library/Ruby/Gems/2.6.0/gems/byebug-11.1.3/ext/byebug
make "DESTDIR ="
make: *** No rule to make target `/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal- darwin19/ruby ​​/ config.h', needed by `breakpoint.o'. Stop.
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/byebug-11.1.3 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/byebug-11.1.3/gem_make.out
What I tried

sudoI tried it with, but it didn't work, and I searched for other methods, but I couldn't find it.

Supplementary information (FW/tool version, etc.)


  • Answer # 1

    You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

    MacOS standard Ruby is installed in the root owner's directory (/ Library),
    General users do not have write permission, so it is difficult to handle.

    $ls -ld/Library
    drwxr-xr-x 71 root wheel 2272 11 29 03:31/Library /

    If you install rbenv, you can install multiple versions of ruby ​​in your home directory.
    It is convenient and recommended because it can be switched.

    $rbenv -v
    rbenv 1.1.2
    $rbenv versions
    * 2.6.6 (set by /Users/username/.rbenv/version)

    ERROR: Failed to build gem native extension.

    Gem compilation fails.
    The development environment is not ready.
    Install Homebrew and Xcode command line tools.

  • Answer # 2


    It seems that the problem is that the permissions of the directory are different.

    ls -la /Library/Ruby/Gems/2.6.0

    What is the result?

    If root privileges are used instead of user privileges, the following commands will return the privileges.

    sudo chown -R $(whoami) /Library/Ruby/Gems/2.6.0

    However, please be careful because it will be troublesome if you make a mistake in the authority system.