athityakumar / colorls

A Ruby gem that beautifies the terminal's ls command, with color and font-awesome icons. :tada:
MIT License
4.9k stars 387 forks source link

Installation failure on MacOS Ventura M1 Pro 10c/16c #606

Open zenideas opened 9 months ago

zenideas commented 9 months ago

This is a mint upgrade from Monterey to Ventura upon unboxing the MBP. Its a 16inch M1 Pro 10core/16core.

When sudo gem install colorls was attempted, it gave the following error at first: `Building native extensions. This could take a while... ERROR: Error installing colorls: ERROR: Failed to build gem native extension.

current directory: /Library/Ruby/Gems/2.6.0/gems/clocale-0.0.4/ext/clocale

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20231215-10876-ti2sgm.rb extconf.rb checking for locale.h... extconf.rb failed Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME) /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:inblock in try_compile' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:534:in with_werror' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:intry_compile' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1109:in block in have_header' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:inblock in checking_for' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in block (2 levels) in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:inopen' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in block in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:inopen' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:inchecking_for' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1108:in have_header' from extconf.rb:9:in

'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/Library/Ruby/Gems/2.6.0/extensions/universal-darwin-22/2.6.0/clocale-0.0.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/clocale-0.0.4 for inspection. Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-22/2.6.0/clocale-0.0.4/gem_make.out`

Then while trying the sudo update_rubygems, following error was displayed: ERROR: While executing gem ... (Errno::EPERM) Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/gem /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1387:ininitialize' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1387:in open' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1387:inblock in copy_file' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1386:in open' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1386:incopy_file' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:492:in copy_file' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:860:inblock in install' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1558:in block in fu_each_src_dest' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1574:infu_each_src_dest0' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1556:in fu_each_src_dest' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:856:ininstall' /Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.22/lib/rubygems/commands/setup_command.rb:268:in block (2 levels) in install_executables' /Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.22/lib/rubygems/commands/setup_command.rb:252:inchdir' /Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.22/lib/rubygems/commands/setup_command.rb:252:in block in install_executables' /Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.22/lib/rubygems/commands/setup_command.rb:249:ineach' /Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.22/lib/rubygems/commands/setup_command.rb:249:in install_executables' /Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.22/lib/rubygems/commands/setup_command.rb:166:inexecute' /Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.22/lib/rubygems/command.rb:328:in invoke_with_build_args' /Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.22/lib/rubygems/command_manager.rb:253:ininvoke_command' /Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.22/lib/rubygems/command_manager.rb:193:in process_args' /Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.22/lib/rubygems/command_manager.rb:151:inrun' /Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.22/lib/rubygems/gem_runner.rb:56:in run' setup.rb:36:in

'`

Now, after again trying sudo gem install colorls: Fetching colorls-1.4.6.gem Fetching rainbow-3.1.1.gem Fetching manpages-0.6.1.gem Fetching filesize-0.2.0.gem Fetching clocale-0.0.4.gem Fetching public_suffix-5.0.4.gem Fetching addressable-2.8.6.gem Fetching unicode-display_width-2.5.0.gem ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory. /Library/Ruby/Site/2.6.0/rubygems/installer.rb:708:inverify_gem_home' /Library/Ruby/Site/2.6.0/rubygems/installer.rb:898:in pre_install_checks' /Library/Ruby/Site/2.6.0/rubygems/installer.rb:303:ininstall' /Library/Ruby/Site/2.6.0/rubygems/resolver/specification.rb:105:in install' /Library/Ruby/Site/2.6.0/rubygems/request_set.rb:195:inblock in install' /Library/Ruby/Site/2.6.0/rubygems/request_set.rb:183:in each' /Library/Ruby/Site/2.6.0/rubygems/request_set.rb:183:ininstall' /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:215:in install_gem' /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:231:inblock in install_gems' /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:224:in each' /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:224:ininstall_gems' /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:170:in execute' /Library/Ruby/Site/2.6.0/rubygems/command.rb:328:ininvoke_with_build_args' /Library/Ruby/Site/2.6.0/rubygems/command_manager.rb:253:in invoke_command' /Library/Ruby/Site/2.6.0/rubygems/command_manager.rb:193:inprocess_args' /Library/Ruby/Site/2.6.0/rubygems/command_manager.rb:151:in run' /Library/Ruby/Site/2.6.0/rubygems/gem_runner.rb:56:inrun' /usr/bin/gem:21:in <main>'

  • Type of issue :
    • [ ] Installation
zenideas commented 9 months ago

The content of mkmf.log is:/Library/Ruby/Gems/2.6.0/extensions/universal-darwin-22/2.6.0/clocale-0.0.4/mkmf.log `"xcrun clang -o conftest -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin22 -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/backward -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -DUSE_FFI_CLOSURE_ALLOC conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib -L. -L/AppleInternal/Library/BuildRoots/d9889869-120b-11ee-b796-7a03568b17ac/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.5.Internal.sdk/usr/local/lib -lruby.2.6 " In file included from conftest.c:1: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found

include "ruby/config.h"

     ^~~~~~~~~~~~~~~

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header 'config.h' in framework 'ruby' (loaded from '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks') 1 error generated. checked program was: / begin / 1: #include "ruby.h" 2: 3: int main(int argc, char *argv) 4: { 5: return 0; 6: } / end */

`

avdv commented 9 months ago

Hi.

According to https://stackoverflow.com/a/68118750/4432837 the Ruby version included by Apple is not really working. You have to install Ruby yourself, e.g. from homebrew -- see https://www.ruby-lang.org/en/documentation/installation/#homebrew

\edit: It might also work if you install the headers with something like sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / (adjust the version to match your system version!)

zenideas commented 9 months ago

Funny thing is I resolved this issue just now and came to check if the issue was addressed yet.

Figured out by myself that I was being served by MacOS's bundled ruby which are of lower version. But I had Ruby 3.2+ installed via Homebrew and I just updated the $PATH when it indicated from in the prompt after trying: brew install ruby It says: echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc

So, after doing this, I had to reload .zshrc by: source ~/.zshrc

And then sudo gem install colorls --user-install works just fine.

Also had to add /Users/lenin/.gem/ruby/3.2.0/bin to $PATH