Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-init Amplify #13104

Closed
2 tasks done
wills721 opened this issue Aug 11, 2023 · 18 comments
Closed
2 tasks done

Re-init Amplify #13104

wills721 opened this issue Aug 11, 2023 · 18 comments
Labels
bug Something isn't working ops-errors Operational theme: centralized error messaging platform-init Issues related to initializing a new Amplify project

Comments

@wills721
Copy link

How did you install the Amplify CLI?

curl

If applicable, what version of Node.js are you using?

No response

Amplify CLI Version

12.2.4

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No

Describe the bug

I tried to re-init my amplify project after attempting to re-init my auth (amplify remove auth). I had a bunch of failures and now I seem stuck. Its odd because the error tells me a dir is missing but its not:

will@Wills-MBP Scanner % amplify init --quickstart --frontend ios
Updating Xcode project:
🚫 folderNotFound: Amplify project not found at "/Users/will/Desktop/Scanner".
-- Recovery suggestion: Run amplify init to initialize an Amplify project.
🛑 Command failed with exit code 1: /Users/will/.amplify/lib/aws-amplify-amplify-frontend-ios/resources/amplify-xcode import-config --path="/Users/will/Desktop/Scanner"

Resolution: Please report this issue at https://github.com/aws-amplify/amplify-cli/issues and include the project identifier from: 'amplify diagnose --send-report'
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

Session Identifier: 2a553097-8c06-4166-bf1e-13685db9bde1

✅ Report saved: /var/folders/4c/983j0hb94z93c8hgwn1mnhw40000gn/T/Scanner/report-1691762388536.zip

✔ Done

Project Identifier: 92e08c1a4705f2c2d32e531a9c530cae

will@Wills-MBP Scanner % pwd
/Users/will/Desktop/Scanner
will@Wills-MBP Scanner %

Is there a way to clean this all up?

Expected behavior

Start over clean but retain my datasources, graphql and REST apis. My goal was just to remove auth and re-install auth but everything seems to have gotten corrupted.

Reproduction steps

amplify remove auth
amplify init

Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@wills721 wills721 added the pending-triage Issue is pending triage label Aug 11, 2023
@ykethan ykethan added the platform-init Issues related to initializing a new Amplify project label Aug 11, 2023
@wills721
Copy link
Author

I actually just tried to completely start over from scratch. I created a brand new xcode ios app....and ran init.....but still it fails?

will@Wills-MBP ThioScanner % amplify init --quickstart --frontend ios
Updating Xcode project:
🚫 folderNotFound: Amplify project not found at "/Users/will/Desktop/ThioScanner".
-- Recovery suggestion: Run amplify init to initialize an Amplify project.
🛑 Command failed with exit code 1: /Users/will/.amplify/lib/aws-amplify-amplify-frontend-ios/resources/amplify-xcode import-config --path="/Users/will/Desktop/ThioScanner"

Resolution: Please report this issue at https://github.com/aws-amplify/amplify-cli/issues and include the project identifier from: 'amplify diagnose --send-report'
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

Session Identifier: 94fba5a2-4563-45c6-9bd9-e245e8a42021
? An unexpected error has occurred, opt in to send an error report to AWS Amplify with non-sensitive project configuration files. Confirm (y/N) ›

@ykethan
Copy link
Contributor

ykethan commented Aug 11, 2023

Hey @wills721, thank you for reaching out. I was able to reproduce the issue but noticed while the error does occur on init, adding resources and push worked as expected.
Marking this as bug for further investigation.

@ykethan ykethan added bug Something isn't working ops-errors Operational theme: centralized error messaging and removed pending-triage Issue is pending triage labels Aug 11, 2023
@wills721
Copy link
Author

Well that's great -- but :) -- it now will not update the xcode project file. Kinda leaves me stuck

@ykethan
Copy link
Contributor

ykethan commented Aug 11, 2023

@wills721 thank you for the information. The issue seems to be related to #12596

from the comment #12596 (comment) as a workaround downgrading to Amplify CLI v12.2.3 appears to mitigate the issue. currently testing this workaround.

@wills721
Copy link
Author

Yes, looks same/similar. How do you downgrade? :)

@lawmicha
Copy link
Member

it now will not update the xcode project file. Kinda leaves me stuck

@wills721 just to clarify, what type of updates do you expect it to do to the project file? Are you referring to the amplifyconfiguration.json / awsconfiguration.json files being added to the project target?

@wills721
Copy link
Author

Not manual updates. Amplify CLI will add to xcode project file......in cases of codegen models as well as the init

@atierian
Copy link
Member

Yes, looks same/similar. How do you downgrade? :)

If you're using npm, you can use npm install -g @aws-amplify/[email protected] to downgrade.

@wills721
Copy link
Author

Nope. I wish. I am on a Mac and used this to install curl -sL https://aws-amplify.github.io/amplify-cli/install | bash && $SHELL

@josefaidt
Copy link
Contributor

Hey @wills721 you can downgrade with the curl approach with the following steps:

  1. amplify uninstall
  2. download the install script from https://aws-amplify.github.io/amplify-cli/install
  3. add a version to the script
  4. execute the script with bash install
#!/bin/sh

set -e

+version=v12.2.3

reset="\033[0m"
red="\033[31m"
green="\033[32m"
yellow="\033[33m"
cyan="\033[36m"
white="\033[37m"

trap errorMessage EXIT

function errorMessage {
  exit_code=$?
  if [ $exit_code -eq 0 ]; then
    exit
  fi
  printf "\n${red}Error: Amplify CLI failed to install. Check your internet connection and try again.$reset\n"
  printf "If this error still occurs, install the CLI using NPM: ${cyan}npm i -g @aws-amplify/cli$reset\n"
}

printf "\n$yellow Installing the AWS Amplify CLI...$reset\n\n"

# Detect platform
if [[ $OSTYPE == "linux-gnu" ]]; then
  PLATFORM="linux"
elif [[ $OSTYPE == "darwin"* ]]; then
  PLATFORM="macos"
else
  echo "$red Sorry, there's no Amplify CLI binary installer available for this platform."
  exit 1
fi

# Detect architecture and fallback to Rosetta when using M1 Macbook
MACHINE_TYPE=`uname -m`
if [[ $MACHINE_TYPE == "x86_64" ]]; then
  ARCH='x64'
elif [[ $OSTYPE == "darwin"* && $MACHINE_TYPE == "arm64" ]]; then
  ARCH='x64'
else
  echo "$red Sorry, there's no Amplify CLI binary installer available for $MACHINE_TYPE architecture."
  exit 1
fi

REPO_OWNER=aws-amplify
REPO_NAME=amplify-cli

if [[ -z "$version" ]]; then
  # if no version specified, look up the latest version
  version=`curl -sL https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest | grep 'tag_name' | grep -oE "v[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?"`
fi

BASE_NAME=amplify-pkg-$PLATFORM
TAR_NAME=${BASE_NAME}.tgz
BINARY_URL=https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/$version/$TAR_NAME

# Dowload binary
BINARIES_DIR_PATH=$HOME/.amplify/bin
BINARY_NAME=amplify
BINARY_PATH=$BINARIES_DIR_PATH/$BINARY_NAME
TAR_PATH=$BINARIES_DIR_PATH/$TAR_NAME
EXTRACTION_PATH=$BINARIES_DIR_PATH/$BASE_NAME
mkdir -p $BINARIES_DIR_PATH

printf "$yellow Downloading binary...\n$reset"
curl -L -o $TAR_PATH $BINARY_URL
printf "$green Download complete!\n$reset"

printf "$yellow Extracting binary...\n$reset"
tar xzf $TAR_PATH -C $BINARIES_DIR_PATH
mv $EXTRACTION_PATH $BINARY_PATH
chmod +x $BINARY_PATH
rm $TAR_PATH
printf "$green Extraction complete!\n$reset"

# Add to $PATH
SOURCE_STR="# Added by Amplify CLI binary installer\nexport PATH=\"\$HOME/.amplify/bin:\$PATH\"\n"
add_to_path () {
  command printf "\n$SOURCE_STR" >> "$1"
  printf "\n$yellow Added the following to $1:\n\n$SOURCE_STR$reset"
}
SHELLTYPE="$(basename "/$SHELL")"
if [[ $SHELLTYPE = "fish" ]]; then
  command fish -c 'set -U fish_user_paths ~/.amplify/bin $fish_user_paths'
  printf "\n$yellow Added ~/.amplify/bin to fish_user_paths universal variable$reset."
elif [[ $SHELLTYPE = "zsh" ]]; then
  SHELL_CONFIG=$HOME/.zshrc
  if [ -r $SHELL_CONFIG ] && (! `grep -q '.amplify/bin' $SHELL_CONFIG`); then
    add_to_path $SHELL_CONFIG
  fi
else
  SHELL_CONFIG=$HOME/.bashrc
  if [ -r $SHELL_CONFIG ] && (! `grep -q '.amplify/bin' $SHELL_CONFIG`); then
    add_to_path $SHELL_CONFIG
  fi
  SHELL_CONFIG=$HOME/.bash_profile
  if [ -r $SHELL_CONFIG ] && (! `grep -q '.amplify/bin' $SHELL_CONFIG`); then
    add_to_path $SHELL_CONFIG
  fi
  SHELL_CONFIG=$HOME/.bash_login
  if [ -r $SHELL_CONFIG ] && (! `grep -q '.amplify/bin' $SHELL_CONFIG`); then
    add_to_path $SHELL_CONFIG
  fi
  SHELL_CONFIG=$HOME/.profile
  if [ -r $SHELL_CONFIG ] && (! `grep -q '.amplify/bin' $SHELL_CONFIG`); then
    add_to_path $SHELL_CONFIG
  fi
fi

$BINARY_PATH plugin scan
printf "$green\nSuccessfully installed the Amplify CLI.\nRun '$BINARY_NAME help' to get started!$reset\n"

@wills721
Copy link
Author

Thank you! That worked!

@wills721
Copy link
Author

I do see one side affect of this......after the downgrade although it all works again every push I get the following error:
Corrupt file contents in /Users/willspies/Desktop/ThioScanner/amplify/.config/local-aws-info.json

@wills721
Copy link
Author

Actually, I think this is causing an issue. At runtime i get this now (I never got this before)
ThioScanner[63378:694017] [AmplifyConfiguration] Unable to read Auth.Default from the configuration
2023-08-11 16:53:28.509716-0400 ThioScann

@wills721
Copy link
Author

wills721 commented Aug 11, 2023

local-aws-info.json now reference's a cloudformation config that does not exist anywhere on my harddrive
{
"dev": {
"configLevel": "project",
"useProfile": false,
"awsConfigFilePath": "/Users/will/.amplify/awscloudformation/zHgTXFRMa9"
}
}

I'm starting to think I need to wipe everything clean now after all this (?)

@josefaidt
Copy link
Contributor

josefaidt commented Aug 15, 2023

Hey @wills721 👋 can you try removing the awsConfigFilePath from the local-aws-info.json and re-pull? Or if that does not work can you run git clean -fXd to remove the gitignored files, and re-pull the project with amplify pull --appId <app-id> --envName <env-name>?

@josefaidt josefaidt added the pending-response Issue is pending response from the issue author label Aug 15, 2023
@wills721
Copy link
Author

Thanks for responding. I spent the day just blowing everything away and recreating from scratch and I'm back in business now.

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Aug 15, 2023
@josefaidt
Copy link
Contributor

Closing as this issue has since been resolved

@josefaidt josefaidt closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ops-errors Operational theme: centralized error messaging platform-init Issues related to initializing a new Amplify project
Projects
None yet
Development

No branches or pull requests

5 participants