0

New to MacOS, tried to install ruby and stupidly used sudo and ended up with Gems in my system version of ruby 2.6.

I have tried to correct this using brew to install the new version of ruby however gems are still being installed in the system directory when I use 'rails new appname'

ruby -v

ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]

Which Ruby returns the below (does not look right to me)

/opt/homebrew/opt/ruby/bin/ruby

If I run rails new app I get the below

        Using rake 13.0.6
    Following files may not be writable, so sudo is needed:
      /Library/Ruby/Gems/2.6.0
      /Library/Ruby/Gems/2.6.0/build_info
      /Library/Ruby/Gems/2.6.0/build_info/nokogiri-1.12.2-x86_64-darwin.info
      /Library/Ruby/Gems/2.6.0/cache
      /Library/Ruby/Gems/2.6.0/doc
      /Library/Ruby/Gems/2.6.0/extensions
      /Library/Ruby/Gems/2.6.0/gems
      /Library/Ruby/Gems/2.6.0/specifications
      /usr/local/bin
.....
.....
Bundle complete! 17 Gemfile dependencies, 73 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
         run  bundle binstubs bundler
       rails  webpacker:install
rails aborted!
LoadError: dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.3/lib/ffi_c.bundle, 0x0009): could not use '/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.3/lib/ffi_c.bundle' because it is not a compatible arch - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.3/lib/ffi_c.bundle

My PATH is as follows

/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin

Any ideas on how I can get this working, all documentation I can find so far is not helping.

Mike
  • 1
  • Does this answer your question? [Installing Ruby with Homebrew](https://stackoverflow.com/questions/12287882/installing-ruby-with-homebrew) – idmean Aug 10 '21 at 05:45
  • Thanks but it doesn't, I installed it with brew. – Mike Aug 10 '21 at 08:34
  • This question specifically concerns Hombrew. Have you tried one of the answers? – idmean Aug 10 '21 at 08:46
  • 1
    I would suggest using some kind of ruby version manager and forget about the system version. I personally use Rbenv https://github.com/rbenv/rbenv You can then set up global ruby or use different ruby versions in different folders. Using the system version is generally a bad idea. – J.Krzus Aug 10 '21 at 15:39
  • 2
    I would completely delete the system ruby and start over with a ruby version manager as @J.Krzus suggests. – Les Nightingill Aug 10 '21 at 15:54
  • Checkout my article - https://medium.com/@vishalsadriya1224/how-to-install-postgresql-node-with-nvm-ruby-with-chruby-rails-in-macbook-pro-m1-chip-4612e0a50260 – Vishal Aug 16 '21 at 06:45

0 Answers0