question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"amplify remove env" fails with "Cannot read property 'message' of null"

See original GitHub issue

Describe the bug I have multiple environments. Most of them are in the same account / profile (called ‘dev’). I have created one with a different profile (called ‘test’). When I try and remove that I get

amplify env remove testse       
Scanning for plugins...
Plugin scan successful
? Are you sure you want to continue? This CANNOT be undone. (This would delete 'testse' environment of the project from the cloud) Yes
⠋ Deleting resources from the cloud. This may take a few minutes...
Deleting env:testse
⠸ Deleting resources from the cloud. This may take a few minutes...
Error in deleting env:testse
✖ remove env failed: Cannot read property 'message' of null
Cannot read property 'message' of null
TypeError: Cannot read property 'message' of null
    at AmplifyToolkit.removeEnvFromCloud [as _removeEnvFromCloud] (/usr/local/lib/node_modules/@aws-amplify/cli/src/extensions/amplify-helpers/remove-env-from-cloud.js:22:26)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/src/commands/env/remove.js:44:11)
    at Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/src/commands/env.js:27:9)
    at Object.executeAmplifyCommand (/usr/local/lib/node_modules/@aws-amplify/cli/src/index.ts:161:3)
    at executePluginModuleCommand (/usr/local/lib/node_modules/@aws-amplify/cli/src/execution-manager.ts:161:3)
    at Object.executeCommand (/usr/local/lib/node_modules/@aws-amplify/cli/src/execution-manager.ts:25:5)
    at Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/src/index.ts:84:5)

I tried this multiple times with the same response. Removing an environment on the profile ‘dev’ works.

 amplify env remove develop
? Are you sure you want to continue? This CANNOT be undone. (This would delete 'develop' environment of the project from the cloud) Yes
⠋ Deleting resources from the cloud. This may take a few minutes...
Deleting env:develop
✔ Successfully removed environment from the cloud
Successfully removed environment from your project locally

I guess this has something to do with some profile being saved wrongly in an autogenerated file?

Amplify CLI Version 4.24.3 and 4.25.0

To Reproduce I have not tried but I assume:

amplify init with aws ‘devProfile’ amplify push git checkout -b test amplify init with aws ‘testProfile’ amplify push

amplify env checkout dev amplify env remove test

Expected behavior Expecting it to remove the environment or at least tell me what the error is.

Desktop (please complete the following information):

  • OS: Mac 10.15.5
  • Node Version. v14.4.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

13reactions
xavierraffincommented, Aug 20, 2020

As @bolenc explain this is because the environment checked out use a profile different than the environment you are trying to delete. Just edit the file amplify/.config/local-aws-info.json and temporarily change the value profile of the current env to the one you need to use for deletion. Once done the command amplify env remove XXX will work.

That being said it is not convenient for the users and the Amplify team should make the fix automatic.

2reactions
xavierraffincommented, Oct 22, 2020

Hey bot, this issue is still occuring

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - aws-amplify ERR: "Cannot read property ...
I have a local React project and initialized @aws-amplify/cli (v. 6.14.13) in the root folder. Command amplify push runs into "Cannot read ......
Read more >
Troubleshoot CloudFormation stack issues in AWS Amplify
1. Open the Amplify console. 2. Choose the Backend environments tab. Then choose your application's backend environment. 3. Choose the Overview ...
Read more >
How to prevent cannot read property split of undefined
The error "Cannot read property split of undefined" can occur when performing any of these types of operations if the variable is undefined....
Read more >
cannot read properties of undefined (reading 'auth') - You.com
Steps to Reproduce · Failure Logs · Environment · Describe the bug · To Reproduce · Code snippet · Expected behavior · Axios...
Read more >
AWS-Amplify/Lobby - Gitter
Hi All, I started seeing an error in production yesterday that says Cannot read property 'configure' of undefined. This a vuejs app using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found