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.