supabase-on-aws icon indicating copy to clipboard operation
supabase-on-aws copied to clipboard

bug : Update from supabase studio version v0.23.09 to v0.23.11.

Open psyrenpark opened this issue 1 year ago • 5 comments

Bug report

I confirm this is a bug with Supabase, not with my own application. I confirm I have searched the Docs, GitHub Discussions, and Discord. Describe the bug While attempting to update the studioBranch to the latest version, I encountered an error. It appears that the directory structure in Supabase has changed between versions v0.23.09 and v0.23.11, particularly the path from /studio to /apps/studio. This change seems to affect the build process, causing it to fail.

To Reproduce Steps to reproduce the behavior:

BUG : Update from supabase studio version v0.23.09 to v0.23.11. Observe the directory change from /studio to /apps/studio. Attempt to build using the current configuration. Notice the build process fails due to the directory change. Expected behavior The build process should adapt to the updated directory structure without causing any errors, or the documentation should provide clear instructions on how to handle such changes in directory paths.

Screenshots If applicable, add screenshots to help explain your problem.

/** BuildSpec for Amplify Hosting */
const buildSpec = BuildSpec.fromObjectToYaml({
    version: 1,
    applications: [{
    appRoot,  // TODO: studio => apps/studio ??
    frontend: {
        phases: {
        preBuild: {
            commands: [
            'echo POSTGRES_PASSWORD=$(aws secretsmanager get-secret-value --secret-id $DB_SECRET_ARN --query SecretString | jq -r . | jq -r .password) >> .env.production',
            'echo SUPABASE_ANON_KEY=$(aws ssm get-parameter --region $SUPABASE_REGION --name $ANON_KEY_NAME --query Parameter.Value) >> .env.production',
            'echo SUPABASE_SERVICE_KEY=$(aws ssm get-parameter --region $SUPABASE_REGION --name $SERVICE_KEY_NAME --query Parameter.Value) >> .env.production',
            'env | grep -e STUDIO_PG_META_URL >> .env.production',
            'env | grep -e SUPABASE_ >> .env.production',
            'env | grep -e NEXT_PUBLIC_ >> .env.production',
            'cd ../',
            'npx [email protected] prune --scope=studio',
            'npm clean-install',
            ],
        },
        build: {
            commands: [
            'npx turbo run build --scope=studio --include-dependencies --no-deps',
            'npm prune --omit=dev',
            ],
        },
        postBuild: {
            commands: [
            `cd ${appRoot}`,
            `rsync -av --ignore-existing .next/standalone/${repository.repositoryName}/${appRoot}/ .next/standalone/`,
            `rsync -av --ignore-existing .next/standalone/${repository.repositoryName}/node_modules/ .next/standalone/node_modules/`,
            `rm -rf .next/standalone/${repository.repositoryName}`,
            'cp .env .env.production .next/standalone/',
            // https://nextjs.org/docs/advanced-features/output-file-tracing#automatically-copying-traced-files
            'rsync -av --ignore-existing public/ .next/standalone/public/',
            'rsync -av --ignore-existing .next/static/ .next/standalone/.next/static/',
            ],
        },
        },
        artifacts: {
        baseDirectory: '.next',
        files: ['**/*'],
        },
        cache: {
        paths: [
            'node_modules/**/*',
        ],
        },
    },
    }],
});

System information

  • amazonlinux 2
  • supabase-on-aws/tree/v0.7.0 -> master

This section indicates the use of 'studio' which may need to be updated to 'apps/studio'.

psyrenpark avatar Jan 30 '24 08:01 psyrenpark

Confirming- directory now exists in subdirectory instead of root

as mentioned in psyrenpark's commit message: https://github.com/supabase/supabase/pull/18915

binury avatar Feb 13 '24 05:02 binury

in addition, the cd' targets in preBuild and postBuild need to be modified and the paths passed to rsync are wrong

version: 1
applications:
  - appRoot: apps/studio
    frontend:
      phases:
        preBuild:
          commands:
            - echo POSTGRES_PASSWORD=$(aws secretsmanager get-secret-value --secret-id $DB_SECRET_ARN --query SecretString | jq -r . | jq -r .password) >> .env.production
            - echo SUPABASE_ANON_KEY=$(aws ssm get-parameter --region $SUPABASE_REGION --name $ANON_KEY_NAME --query Parameter.Value) >> .env.production
            - echo SUPABASE_SERVICE_KEY=$(aws ssm get-parameter --region $SUPABASE_REGION --name $SERVICE_KEY_NAME --query Parameter.Value) >> .env.production
            - env | grep -e STUDIO_PG_META_URL >> .env.production
            - env | grep -e SUPABASE_ >> .env.production
            - env | grep -e NEXT_PUBLIC_ >> .env.production
            - cd ../../
            - npx [email protected] prune --scope=studio
            - npm clean-install
        build:
          commands:
            - npx turbo run build --scope=studio --include-dependencies --no-deps
            - npm prune --omit=dev
        postBuild:
          commands:
            - cd apps/studio
            - rsync -av --ignore-existing .next/standalone/apps/studio/ .next/standalone
            - rsync -av --ignore-existing .next/standalone/node_modules/ .next/standalone/node_modules
            - rm -rf .next/standalone/apps
            - cp .env .env.production .next/standalone/
            - rsync -av --ignore-existing public/ .next/standalone/public
            - rsync -av --ignore-existing .next/static/ .next/standalone/.next/static
      artifacts:
        baseDirectory: .next
        files:
          - "**/*"
      cache:
        paths:
          - node_modules/**/*

binury avatar Feb 13 '24 05:02 binury

has anyone got this working?

bhaktatejas922 avatar Mar 05 '24 09:03 bhaktatejas922

@binury I see this when running with your changes

Updating files: 100% (8503/8503)
Updating files: 100% (8503/8503), done.
2024-03-05T09:56:26.651Z [INFO]: # Switching to commit: ae8ce04f16e603d5bdf84c709fff649ebf4b55f1
2024-03-05T09:56:27.082Z [INFO]: Note: switching to 'ae8ce04f16e603d5bdf84c709fff649ebf4b55f1'.
                                 You are in 'detached HEAD' state. You can look around, make experimental
                                 changes and commit them, and you can discard any commits you make in this
                                 state without impacting any branches by switching back to a branch.
                                 If you want to create a new branch to retain commits you create, you may
                                 do so (now or later) by using -c with the switch command. Example:
                                 git switch -c <new-branch-name>
                                 Or undo this operation with:
                                 git switch -
                                 Turn off this advice by setting config variable advice.detachedHead to false
                                 HEAD is now at ae8ce04f1 chore: .env file pull for www (#19511)
2024-03-05T09:56:27.095Z [INFO]: Successfully cleaned up Git credentials
2024-03-05T09:56:27.095Z [INFO]: # Checking for Git submodules at: /codebuild/output/src2868321510/src/Supabase/.gitmodules
2024-03-05T09:56:27.101Z [ERROR]: !!! CustomerError: Cannot read 'next' version in package.json.
                                  If you are using monorepo, please ensure that AMPLIFY_MONOREPO_APP_ROOT is set correctly.
                                  Learn More: https://docs.aws.amazon.com/amplify/latest/userguide/monorepo-configuration.html#setting-monorepo-environment-variable
2024-03-05T09:56:27.101Z [INFO]: # Starting environment caching...
2024-03-05T09:56:27.102Z [INFO]: # Environment caching completed

bhaktatejas922 avatar Mar 05 '24 23:03 bhaktatejas922

The workaround that worked for me was bumping the deployed version back down to 0.23.09. And then making any changes you would want to make.

michaelwang11394 avatar Jun 28 '24 21:06 michaelwang11394