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

Warning: Amplify command hooks are disabled in the current execution environment. See https://docs.amplify.aws/cli/usage/runtime-hooks for more information. #8147

Closed
4 tasks done
maydna opened this issue Sep 10, 2021 · 9 comments
Assignees
Labels
pending-response Issue is pending response from the issue author pending-triage Issue is pending triage platform Issues tied to the general CLI platform

Comments

@maydna
Copy link

maydna commented Sep 10, 2021

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

How did you install the Amplify CLI?

npm install -g @aws-amplify/cli@latest

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

v14.15.4

Amplify CLI Version

5.5.0

What operating system are you using?

MacOS

Amplify Categories

Not applicable

Amplify Commands

push

Describe the bug

i would like to use the new command hooks function introduced by amplify cli 5.5.0 and i already have a pre-push.js copied from the sample in amplify/hooks. the pre-push.js is as below:

const hookHandler = async (data, error) => {
  // TODO write your hook handler here
  console.log(data,error)
};

const getParameters = async () => {
  const fs = require("fs");
  return JSON.parse(fs.readFileSync(0, { encoding: "utf8" }));
};

getParameters()
  .then((event) => hookHandler(event.data, event.error))
  .catch((err) => {
    console.error(err);
    process.exitCode = 1;
  });

however after i run amplify push the following warning pops up:

⚠️ Amplify command hooks are disabled in the current execution environment.
⚠️ See https://docs.amplify.aws/cli/usage/runtime-hooks for more information.
✔ Successfully pulled backend environment dev from the cloud.

    Current Environment: dev

and there's no output for my console.log(data,error) script

Expected behavior

should be no warning & print out the results from console.log(data,error)

Reproduction steps

npm install -g @aws-amplify/cli@latest
amplify version
-> 5.5.0
amplify push

GraphQL schema(s)

# Put schemas below this line

Log output

# Put your logs below this line


Additional information

btw the https://docs.amplify.aws/cli/usage/runtime-hooks/ link is incorrect / not ready yet. i tried to find how to "enable" the command hooks in https://docs.amplify.aws/cli/usage/command-hooks/ but still no luck.

@jhockett
Copy link
Contributor

Hi @maydna, thanks for reporting the issue! I've opened a PR to fix the broken docs link.

Do you have a folder path in your project that resembles /opt/amazon?

@jhockett jhockett added pending-triage Issue is pending triage platform Issues tied to the general CLI platform labels Sep 10, 2021
@maydna
Copy link
Author

maydna commented Sep 10, 2021

Hi @maydna, thanks for reporting the issue! I've opened a PR to fix the broken docs link.

Do you have a folder path in your project that resembles /opt/amazon?

thanks. no there isn't any path like /opt/amazon in my project.
fyi the/amplify folder is like below.
Screenshot 2021-09-10 at 1 58 31 PM

@akshbhu
Copy link
Contributor

akshbhu commented Sep 10, 2021

hi @maydna

Do you have folder path in your system (not in amplify project) with opt/amazon?

@maydna
Copy link
Author

maydna commented Sep 11, 2021

there's one in /opt/amazon but the content here are outdated (last update 2019) and not related to amplify

➜  / cd opt/amazon 
➜  amazon ls
redshift
➜  amazon ll
total 0
drwxr-xr-x  7 root  wheel   224B 20 Jun  2019 redshift
➜  amazon 

hi @maydna

Do you have folder path in your system (not in amplify project) with opt/amazon?

@akshbhu
Copy link
Contributor

akshbhu commented Sep 11, 2021

For the workaround , can you try to remove the folder and try again?
By the time we will look in to this.

@maydna
Copy link
Author

maydna commented Sep 11, 2021

For the workaround , can you try to remove the folder and try again?
By the time we will look in to this.

thanks. i removed it but the warning is still there.

➜  myproject git:(dev) ✗ rm -rf opt/amazon
➜  myproject git:(dev) ✗ cd opt/amazon    
cd: no such file or directory: opt/amazon
➜  myproject git:(dev) ✗ amplify push     
⚠️ Amplify command hooks are disabled in the current execution environment.
⚠️ See https://docs.amplify.aws/cli/usage/runtime-hooks for more information.

@josefaidt
Copy link
Contributor

Hey @maydna 👋 are you still experiencing this issue? From the console snippets you've added it looks like there is a folder /opt/amazon however the rm -rf opt/amazon from the latest snippet looks like it tried to remove the folder relative to your project's folder. Can you verify wether ls /opt/amazon still shows contents?

@josefaidt josefaidt self-assigned this Oct 15, 2021
@josefaidt josefaidt added the pending-response Issue is pending response from the issue author label Oct 15, 2021
@maydna
Copy link
Author

maydna commented Oct 27, 2021

it works after remove /opt/amazon! thanks

➜  git:(dev) amplify push    

----- 🪝 pre-push execution start -----
Please install jq to run the sample script.
----- 🪝 pre-push execution end -----

✔ Successfully pulled backend environment xxx from the cloud.

@maydna maydna closed this as completed Oct 27, 2021
@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pending-response Issue is pending response from the issue author pending-triage Issue is pending triage platform Issues tied to the general CLI platform
Projects
None yet
Development

No branches or pull requests

4 participants