Could not find gem 'sprockets-rails' in any of the gem sources listed in your Gemfile.

Errno::EACCES: Permission denied @ dir_s_mkdir - /Users/xxxx/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-20/2.7.0/racc-1.6.0
  An error occurred while installing racc (1.6.0), and Bundler cannot continue.
  Make sure that `gem install racc -v '1.6.0' --source 'https://rubygems.org/'` succeeds before bundling.
  
  In Gemfile:
    rails was resolved to 7.0.3, which depends on
      actioncable was resolved to 7.0.3, which depends on
        actionpack was resolved to 7.0.3, which depends on
          actionview was resolved to 7.0.3, which depends on
            rails-dom-testing was resolved to 2.0.3, which depends on
              nokogiri was resolved to 1.13.6, which depends on
                racc
           run  bundle binstubs bundler
  Could not find gem 'sprockets-rails' in any of the gem sources listed in your Gemfile.
         rails  importmap:install
  Could not find gem 'sprockets-rails' in any of the gem sources listed in your Gemfile.
  Run `bundle install` to install missing gems.
         rails  turbo:install stimulus:install
  Could not find gem 'sprockets-rails' in any of the gem sources listed in your Gemfile.
  Run `bundle install` to install missing gems.
  

rails newを実行したところ上記のエラーが発生した

色々検索してみたところ権限周りが悪さをしているようなので

sudo rails newというようにsudoをつけて実行してみると問題なく生成された