Why am i getting a series of error messages like these after an extension is created

Hi I created a new Shopify app using npm init @Shopify_77 /app@latest -- --template=node and was able to run npm run dev. However, after I create an extension with npm run generate extension, when I tried running npm run dev again, I started to receive the following error messages

22:25:21 │ web-backend  │  ELIFECYCLE  Command failed.

── external error ──────────────────────────────────────────────────────────────

Error coming from `bundle install`

Command failed with exit code 5: bundle install
Retrying download gem from https://rubygems.org/ due to error (2/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/ast-2.4.2.gem`. It is likely that you need to grant
write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (3/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/ast-2.4.2.gem`. It is likely that you need to grant
write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (2/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/liquid-5.4.0.gem`. It is likely that you need to
grant write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (4/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/ast-2.4.2.gem`. It is likely that you need to grant
write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (3/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/liquid-5.4.0.gem`. It is likely that you need to
grant write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (4/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/liquid-5.4.0.gem`. It is likely that you need to
grant write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (2/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/concurrent-ruby-1.2.2.gem`. It is likely that you
need to grant write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (2/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/ffi-1.16.3.gem`. It is likely that you need to grant
write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (3/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/concurrent-ruby-1.2.2.gem`. It is likely that you
need to grant write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (2/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/rb-fsevent-0.11.2.gem`. It is likely that you need to
 grant write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (3/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/rb-fsevent-0.11.2.gem`. It is likely that you need to
 grant write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (2/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/racc-1.7.3.gem`. It is likely that you need to grant
write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (3/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/ffi-1.16.3.gem`. It is likely that you need to grant
write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (4/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/concurrent-ruby-1.2.2.gem`. It is likely that you
need to grant write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (3/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/racc-1.7.3.gem`. It is likely that you need to grant
write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (4/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/rb-fsevent-0.11.2.gem`. It is likely that you need to
 grant write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (4/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/racc-1.7.3.gem`. It is likely that you need to grant
write permissions for that path.
Retrying download gem from https://rubygems.org/ due to error (4/4): Bundler::PermissionError There was an
error while trying to write to `/var/lib/gems/3.0.0/cache/ffi-1.16.3.gem`. It is likely that you need to grant
write permissions for that path.
Bundler::PermissionError: There was an error while trying to write to
`/var/lib/gems/3.0.0/cache/ast-2.4.2.gem`. It is likely that you need to grant
write permissions for that path.
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/shared_helpers.rb:105:in
`rescue in filesystem_access'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/shared_helpers.rb:102:in
`filesystem_access'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/rubygems_integration.rb:483:in
`block in download_gem'
  /var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/retry.rb:40:in `run'
  /var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/retry.rb:30:in `attempt'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/rubygems_integration.rb:474:in
`download_gem'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/source/rubygems.rb:484:in
`download_gem'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/source/rubygems.rb:446:in
`fetch_gem'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/source/rubygems.rb:430:in
`fetch_gem_if_possible'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/source/rubygems.rb:160:in
`install'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/installer/gem_installer.rb:54:in
`install'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/installer/parallel_installer.rb:156:in
`do_install'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/installer/parallel_installer.rb:147:in
`block in worker_pool'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/worker.rb:62:in
`apply_func'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/worker.rb:57:in `block in
process_queue'
  /var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/worker.rb:54:in `loop'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/worker.rb:54:in
`process_queue'
/var/lib/gems/3.0.0/gems/bundler-2.4.16/lib/bundler/worker.rb:90:in `block (2
levels) in create_threads'

An error occurred while installing ast (2.4.2), and Bundler cannot continue.

In Gemfile:
  theme-check was resolved to 1.15.0, which depends on
    parser was resolved to 3.2.2.4, which depends on
      ast
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using bundler 2.4.16
Fetching ast 2.4.2
Fetching concurrent-ruby 1.2.2
Fetching liquid 5.4.0
Fetching ffi 1.16.3

Fetching rb-fsevent 0.11.2

Fetching racc 1.7.3

Why is this happ

The error message is indicating that there’s a permission issue when to write to the gem cache directory (/var/lib/gems/3.0.0/cache/). This often happens because some of the gem files are owned by root or another user, or the permissions are set incorrectly.

Can you run the following command:

sudo chown -R $USER /var/lib/gems/

This command changes the owner of all files and directories under /var/lib/gems/ to the current user. If changing the owner doesn’t solve the problem, you can try to change the permissions of directory.

It turned out to be a package issue. The solution I found was to use pnpm instead of npm and set both of the shopify packages in package.json in the root directory to 3.48.2. I then remove the lock file and node_modules folder and run pnpm i again.