When deploying with Amplify 4.9.0 from the Amplify Console deploy pipline, I see the following error:
{ UndeterminedEnvironmentError: Current environment cannot be determined
Use 'amplify init' in the root of your app directory to initialize your project with Amplify
at getEnvInfo (/root/.nvm/versions/node/v10.16.0/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/get-env-info.js:19:15)
at AmplifyToolkit.getProjectDetails [as _getProjectDetails] (/root/.nvm/versions/node/v10.16.0/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/get-project-details.js:14:26)
at Object.run (/root/.nvm/versions/node/v10.16.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/amplify-service-migrate.js:9:42)
at Object.run (/root/.nvm/versions/node/v10.16.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/lib/initializer.js:80:33)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3) name: 'UndeterminedEnvironmentError' }
It appears that the code in some Amplify console migration code is not setup to run before the amplify/.config/local-env-info.json is created
To workaround the issue, I added the following script before the amplifyPush --simple command:
echo "{ \"projectPath\": \"$(pwd)\", \"envName\": \"${AWS_BRANCH}\"}" > amplify/.config/local-env-info.json
i have the same problem when try to deploy in the amplify console , it was fixed adding
- nvm use $VERSION_NODE_10
- npm install -g @aws-amplify/[email protected]
before
- amplifyPush --simple
in build settings.
Do you mean 4.11? I've just downgraded from 4.12 to 4.11 and worked.
excerpt amplify.yml
version: 0.1
backend:
phases:
preBuild:
commands:
- npm install -g @aws-amplify/[email protected] # pinned known working version
The fix for this issue has been pushed out in the latest version of the CLI >=4.13.1
@kaustavghosh06 @UnleashedMind I still see this error, using
npm list -g --depth=0
myuserpath/.nvm/versions/node/v13.2.0/lib
├── @aws-amplify/[email protected]
└── [email protected]
git clone ... myrepo
cd myrepo
git checkout dev
npm install
amplify env checkout dev
Current environment cannot be determined
Use 'amplify init' in the root of your app directory to initialize your project with Amplify
UndeterminedEnvironmentError: Current environment cannot be determined
Use 'amplify init' in the root of your app directory to initialize your project with Amplify
at getEnvInfo (myuserpath/.nvm/versions/node/v13.2.0/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/get-env-info.js:18:15)
at Object.run (myuserpath/.nvm/versions/node/v13.2.0/lib/node_modules/@aws-amplify/cli/lib/commands/env/checkout.js:17:30)
at Object.run (myuserpath/.nvm/versions/node/v13.2.0/lib/node_modules/@aws-amplify/cli/lib/commands/env.js:25:37)
at Object.executeAmplifyCommand (myuserpath/.nvm/versions/node/v13.2.0/lib/node_modules/@aws-amplify/cli/lib/index.js:94:25)
at executePluginModuleCommand (myuserpath/.nvm/versions/node/v13.2.0/lib/node_modules/@aws-amplify/cli/lib/execution-manager.js:47:32)
at async Object.executeCommand (myuserpath/.nvm/versions/node/v13.2.0/lib/node_modules/@aws-amplify/cli/lib/execution-manager.js:15:9)
at async Object.run (myuserpath/.nvm/versions/node/v13.2.0/lib/node_modules/@aws-amplify/cli/lib/index.js:41:9)
UPDATE: user error
I just needed to follow the instructions.
$ amplify init
Note: It is recommended to run this command from the root of your app directory
? Do you want to use an existing environment? Yes
? Choose the environment you would like to use: dev
Most helpful comment
To workaround the issue, I added the following script before the
amplifyPush --simplecommand: