alexa / ask-toolkit-for-vscode

ASK Toolkit is an extension for Visual Studio Code (VSC) that that makes it easier for developers to develop and deploy Alexa Skills.
https://developer.amazon.com/en-US/docs/alexa/ask-toolkit/get-started-with-the-ask-toolkit-for-visual-studio-code.html
Apache License 2.0
109 stars 53 forks source link

Unable to download files on local machine #59

Closed khac closed 4 years ago

khac commented 4 years ago

Unable to Download and edit skill on VS Code

When I open the ASK Toolkit and Create Alexa-hosted skill I can see the change in the developer console, but I am unable to get the files downloaded locally on the machine.

The error message I get is

Skill creation failed. Reason: Git folder setup failed for /Users/a/Desktop/AlexaSkills/hello123. Reason: Failed to execute git {
  "exitCode": 1,
  "gitCommand": "checkout",
  "stdout": "",
  "stderr": "error: pathspec 'prod' did not match any file(s) known to git\n"
}

I believe the error is because I am currently not in sync with the Amazon developer console.

nikhilym commented 4 years ago

@khac , thanks for logging the bug. This seems to be similar to the bug #54 . We figured the issue is with respect to a bug in our clone skill functionality and fixed it through the PR #56 . However, that fix has not been released in the extension.

Sorry for the inconvenience. We will be working on releasing the patch soon.

In the mean time, to get around this, you can manually install the earlier version of the toolkit from the marketplace and try creating/downloading the skills. Once downloaded, for using the latest toolkit features you can upgrade it back to the latest version. We understand this is painful, is not the best developer experience and will try to address this through our next release ASAP.

khac commented 4 years ago

@nikhilym, I installed an older version, v2.0.2 The error was the same when I tried to Create an Alexa-hosted skill, at the same time, I was able to see the skill being created on the Alexa developer console.

Skill creation failed. Reason: Git folder setup failed for /Users/a/Desktop/AlexaSkills/qwer123. Reason: Failed to execute git { "exitCode": 1, "gitCommand": "checkout", "stdout": "", "stderr": "error: pathspec 'prod' did not match any file(s) known to git\n" }
nikhilym commented 4 years ago

Interesting. I was not able to reproduce this error. Can you please provide some more details about your toolkit configuration? Please run Alexa: About Alexa Skill Toolkit command from command palette, and paste that information here. For context, here is my toolkit configuration :

OS: Darwin x64 19.6.0
Visual Studio Code Version:  1.51.1
Alexa Skills Toolkit Version: 2.1.0
Git Version: git version 2.29.2

Also, can you try downloading the skill and see if the issue persists? Is it happening for an existing skill as well or only for a new skill?

SpellMender commented 4 years ago

Any news on the update? I'm having the same problem.

SpellMender commented 4 years ago

@nikhilym here is what shows up when I run Alexa: About Alexa Skill Toolkit alexa

Chih-Ying commented 4 years ago

@SpellMender @khac Thanks for reporting. Are you able to run git fetch, git checkout prod and git checkout master in the skill root directory using the command line? Also, is it happening for an existing skill as well or only for a new skill??

khac commented 4 years ago

@nikhilym @Chih-Ying OS: Darwin x64 19.6.0 Visual Studio Code Version: 1.51.1 Alexa Skills Toolkit Version: 2.1.0 Git Version: git version 2.28.0

My git is connected to my github.com account, not the Alexa or AWS account, I was able to download the files from Amazon Developer Console

coolbigbear commented 4 years ago

Having the same issue. OS: Windows_NT x64 10.0.19042 Visual Studio Code Version: 1.51.1 Alexa Skills Toolkit Version: 2.1.0 Git Version: git version 2.23.0.windows.1

Clicking on Download and edit skill also does nothing. Error: Skill creation failed. Reason: Git folder setup failed for ...\AlexaSkills\test-test\test-test. Reason: Failed to execute git { "exitCode": 128, "gitErrorCode": "AuthenticationFailed", "gitCommand": "fetch", "stdout": "", "stderr": "...\.ask\\scripts\\git-credential-helper: line 11: ${configFile}: ambiguous redirect\n ...\.ask\\scripts\\git-credential-helper: line 11: ${configFile}: ambiguous redirect\nfatal: Authentication failed for 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/8b1aa862-0611-47fa-80bf-f6c054a0828c/'\n" }

I can execute git fetch just fine

Chih-Ying commented 4 years ago

@nikhilym @Chih-Ying OS: Darwin x64 19.6.0 Visual Studio Code Version: 1.51.1 Alexa Skills Toolkit Version: 2.1.0 Git Version: git version 2.28.0

My git is connected to my github.com account, not the Alexa or AWS account, I was able to download the files from Amazon Developer Console

  • Kindly let me know how to connect again to the git repository on the cloud to run the git commands.

@khac The ASK Toolkit extension automatically initializes git and configures git credentials for users, so users can access the AWS CodeCommit repository that the hosted skill resides at. This git is using a different account from your personal git account.

More information you can look into FAQs:Why do I get a prompt for Git credentials when an Alexa hosted skill is created or downloaded?

Can you successfully run git fetch, git checkout prod and git checkout master in the skill root folder without error messages? Can you share the error messages if any?

Chih-Ying commented 4 years ago

@khac @SpellMender @coolbigbear We observed the Download and edit skill does not work in the latest Visual Studio Code(version 1.51). We are currently investigating.

To unblock your work, please downgrade your Visual Studio Code to 1.50 <= , Please let us know if skill creation and downloading still do not work.

coolbigbear commented 4 years ago

Downgrading to 1.49.3 does make Download and edit skill button work. However, it fails later with the same issue I mentioned (Skill creation failed. Reason: Git folder setup failed for), git fetch also did not work this time.

I managed to fix it by simply adding quotes around ${configFile} inside the git-credential-helper. Specifically:

  1. Opened git-credential-helper in notepad. For me located in C:\Users\<user_name>\.ask\scripts
  2. Changed the ${configFile} on this line askRefreshToken=$(tr -d '\n' < ${configFile} | tr -d ' ' | sed -n $configOp | sed 's/".*//') to be surrounded by quotes i.e. "${configFile}"
  3. git fetch worked fine in the directory now and using Download and edit skill while on VSCode version = 1.49.3 works.
coolbigbear commented 4 years ago

Downgrading to 1.49.3 does make Download and edit skill button work. However, it fails later with the same issue I mentioned (Skill creation failed. Reason: Git folder setup failed for), git fetch also did not work this time.

I managed to fix it by simply adding quotes around ${configFile} inside the git-credential-helper. Specifically:

  1. Opened git-credential-helper in notepad. For me located in C:\Users\<user_name>\.ask\scripts
  2. Changed the ${configFile} on this line askRefreshToken=$(tr -d '\n' < ${configFile} | tr -d ' ' | sed -n $configOp | sed 's/".*//') to be surrounded by quotes i.e. "${configFile}"
  3. git fetch worked fine in the directory now and using Download and edit skill while on VSCode version = 1.49.3 works.

Pushing updates failed due to the same error but in ask-pre-push script inside the same directory. Identical fix worked

SpellMender commented 4 years ago

@Chih-Ying

When I run git fetch: image

When I run git checkout prod: image

When I run git checkout master: image

Also, it happens for both new and existing skills. As mentioned above, you can't use the ASK in VSCode to retrieve an existing skill, but you can do it from Alexa Developer Console via this menu: image

The result is always the same though.

Chih-Ying commented 4 years ago

Downgrading to 1.49.3 does make Download and edit skill button work. However, it fails later with the same issue I mentioned (Skill creation failed. Reason: Git folder setup failed for), git fetch also did not work this time. I managed to fix it by simply adding quotes around ${configFile} inside the git-credential-helper. Specifically:

  1. Opened git-credential-helper in notepad. For me located in C:\Users\<user_name>\.ask\scripts
  2. Changed the ${configFile} on this line askRefreshToken=$(tr -d '\n' < ${configFile} | tr -d ' ' | sed -n $configOp | sed 's/".*//') to be surrounded by quotes i.e. "${configFile}"
  3. git fetch worked fine in the directory now and using Download and edit skill while on VSCode version = 1.49.3 works.

Pushing updates failed due to the same error but in ask-pre-push script inside the same directory. Identical fix worked

@coolbigbear
It’s nice to hear this solution works for you!

I was thinking about this solution as well, but I could not reproduce skill creation fail on Windows

OS: Windows_NT x64 10.0.17763
Visual Studio Code Version: 1.51.1
Alexa Skills Toolkit Version: 2.1.0
Git Version: 2.23.0.windows.1

and Mac

OS: Darwin x64 18.7.0
Visual Studio Code Version:  1.51.0
Alexa Skills Toolkit Version: 2.1.0
Git Version: git version 2.28.0

@SpellMender Thanks for your report. Could you also try the solution @coolbigbear provided?

We will consider these environment settings into our test cases.

SpellMender commented 4 years ago

@Chih-Ying I've already attempted his solution. Unfortunately I can't find the .ask\script folder. In fact, my .ask folder is completely blank. I've tried to create a new skill via ASK, and I've tried to use a current skill. Same issue with both attempts. I will try to roll back the VSCode version to see if that helps, but I have my doubts. @coolbigbear if you have any suggestions to reproduce those results I'd love to hear them.

Chih-Ying commented 4 years ago

@SpellMender According to your git fetch error message above, I saw you have the file in C:\Users\<your_user_name>\.ask\scripts\git-credential-helper. The .ask folder is not located at your skill project, but in your system at C:\Users\<your_user_name>\.ask.

coolbigbear commented 4 years ago

@SpellMender Looks like you have the exact same issue as me. Look in your C:\Users\Michael Kellet\.ask\scripts folder, should be located there You'd also need to fix the ask-pre-push script while you're in there to be able to push changes.

SpellMender commented 4 years ago

Thanks! Sorry for the confusion. I'll try that out and report back.

SpellMender commented 4 years ago

Excellent! @coolbigbear's solution worked for me! I didn't even have to revert back to a different version of VSCode!

From start to finish, here's the process for me to export a skill from the Amazon Developer Console to VSCode: 1) From the Alexa Developer Console go to the "Code" tab image 2) Select "Offline Tools" on the toolbar above the code image 3) Select "Export to VSCode" image 4) You will be prompted to select a folder to load your project into. You don't have to create a new folder. A folder with the name of your project will be created for you. Then the project will fail with the error Skill clone failed. Reason: Git folder setup failed image 5) Open a new Explorer window and navigate to C:\Users\<your_user_name>\.ask\scripts\ image 6) Both of these files need to be edited. Double-click and open with your favorite text editor (in my case it was Notepad++) image 7) Both of those files have a line beginning with askRefreshToken=.

askRefreshToken=$(tr -d '\n' < ${configFile} | tr -d ' ' | sed -n $configOp | sed 's/".*//')

You must add double quotes around ${ConfigFile} for both files. Be sure to save your changes.

askRefreshToken=$(tr -d '\n' < "${configFile}" | tr -d ' ' | sed -n $configOp | sed 's/".*//')

8) Now navigate back to VSCode and make sure to open the folder with your skill (if its not already opened) in your workspace. image 9) Open up a Terminal image 10) Type the command git fetch and press enter. Type the command git checkout dev and press enter. image

You will now see files populate in your workspace: image

I figured if anyone on the internet is as visual a learner as I am, this should be helpful.

I'm hoping there is a quicker, easier resolution found soon.

EDIT: You should probably use git checkout master and git checkout prod as well. I used git checkout dev in the example above because that seems to be the branch that is associated with the code you actually edit in the Alexa Developer Console.

coolbigbear commented 4 years ago

@SpellMender Great to hear it worked for you!

doctor-iksterog commented 4 years ago

well, it seems to work for me when i use the Export to VS Code in Dev Console and that creates the directory and exports and open my skill WITHOUT errors. So i guess i will just stick with that. If i ever have to create a new skill i guess i will have to create it first in dev console then open it up in VS Code.

SpellMender commented 4 years ago

@Chih-Ying @nikhilym This morning I Exported from the developer console via my laptop on a fresh install of VSCode and everything worked without any errors! Perhaps the issue has been resolved! Please also make sure to resolve referenced issue #54 if you deem it solved.

nikhilym commented 4 years ago

@SpellMender @khac @coolbigbear @doctor-iksterog sorry for the late response and thanks for keeping this thread super active and updated on the progress. Special thanks to @coolbigbear & @SpellMender to debug and help us resolve the issue. As a small token of appreciation, we added your github user names in our Thank you section in the toolkit updates view. Anyone can view the toolkit updates view again, in the extension, by running the Alexa: Show Toolkit Update notes command in the vscode command palette.

@Chih-Ying fixed the scripts and released them recently. As @SpellMender observed, the recent extension release v2.2.0 should have these issues fixed.

If i ever have to create a new skill i guess i will have to create it first in dev console then open it up in VS Code.

@doctor-iksterog , we hope the latest extension release fixes this for you. The create skill view from the extension should work flawlessly for you now. Sorry for the inconvenience.

I am going ahead and closing this and #54 issue. Please let us know if you are still facing problems. It would also be great if you can let us know of any feedback, feature requests or issues around the extension. Hope you are finding the extension useful 😄

HimanshuPrimo commented 1 year ago

I am getting this error while cloning the code from the Alexa Developer console on Ubuntu.

Skill clone failed. Reason: Command failed: git branch --show-current

image

Could anyone please let me what I have to do for fix this issue? OS- Ubuntu

tydonelson commented 1 year ago

Hey @HimanshuPrimo , do you have git installed on your machine? Per the prerequisites here, the ASK VSCode extension requires at least version 2.27 of Git to be installed.

HimanshuPrimo commented 1 year ago

Hi @tydonelson,

Thanks for the response. It has been really helpful, and I greatly appreciate it. I had an older version of Git, but the issue has now been resolved.