diff --git a/packages/amplify-cli/src/attach-backend.ts b/packages/amplify-cli/src/attach-backend.ts index 81af52445d5..68b74535c29 100644 --- a/packages/amplify-cli/src/attach-backend.ts +++ b/packages/amplify-cli/src/attach-backend.ts @@ -104,8 +104,16 @@ function backupAmplifyFolder() { throw error; } - - fs.moveSync(amplifyDirPath, backupAmplifyDirPath); + try { + fs.moveSync(amplifyDirPath, backupAmplifyDirPath); + } catch (e) { + if (e.code === 'EPERM') { + throw new Error( + 'Could not attach the backend to the project. Ensure that there are no applications locking the `amplify` folder and try again', + ); + } + throw e; + } } }