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

Action Failed #108

Closed
AceCoderLaura opened this issue Mar 1, 2021 · 19 comments
Closed

Action Failed #108

AceCoderLaura opened this issue Mar 1, 2021 · 19 comments

Comments

@AceCoderLaura
Copy link
Contributor

I added this action to my workflow but it seems to have failed. Here's the log from the Actions run:

Run android-actions/setup-android@v2
  env:
    BUILD_CONFIGURATION: Release
    SOLUTION_FILE_PATH: src\Adapt.Presentation.XamarinForms.sln
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\actions-runner\_work\_temp\1a1339f9-26c7-4f5f-b738-0c7d74ff2dc8', 'C:\actions-runner\_work\_temp\903f36fd-72ff-4212-8fd9-291663a9a96e')"
(node:7968) UnhandledPromiseRejectionWarning: Error: Unable to locate executable file: C:\actions-runner\_work\_temp\903f36fd-72ff-4212-8fd9-291663a9a96e\tools\bin\sdkmanager.bat. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
    at Object.<anonymous> (C:\actions-runner\_work\_actions\android-actions\setup-android\v2\dist\index.js:1:2585)
    at Generator.next (<anonymous>)
    at fulfilled (C:\actions-runner\_work\_actions\android-actions\setup-android\v2\dist\index.js:1:601)
(node:7968) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7968) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@ViliusSutkus89
Copy link
Collaborator

@daveol , I'm 80% sure this error wouldn't happen with updated version. Any chance to tag a release?

@AceCoderLaura , in the meantime, you can use my fork or fork and tag it yourself. No promises to keep my fork up forever though.

- name: Setup Android SDK
  uses: ViliusSutkus89/setup-android@v2.0.3-rc1

@ViliusSutkus89
Copy link
Collaborator

@AceCoderLaura , You should be able to use android-actions/setup-android@v2 now, re-run the failing workflow to see if it works now.

@daveol , Welcome to the project! 😄

@AceCoderLaura
Copy link
Contributor Author

@ViliusSutkus89 Cheers, I'll test it now and let you know how it goes.

@AceCoderLaura
Copy link
Contributor Author

It seems to run correctly now. Although the ANDROID_SDK_ROOT environment variable doesn't appear to be set. That's probably a separate issue though.

@AceCoderLaura
Copy link
Contributor Author

Oh, it might be due to this new error that must've started appearing after the first successful run.

Run android-actions/setup-android@v2
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\actions-runner\_work\_temp\16ff75f4-df58-4d90-9c41-4480f60c45c7', 'C:\actions-runner\_work\_temp\351f9f94-7883-436f-a3b7-7f5cbe75c384')"
(node:7028) UnhandledPromiseRejectionWarning: Error: dest already exists.
    at doRename (C:\actions-runner\_work\_actions\android-actions\setup-android\v2\dist\index.js:1:17873)
    at Object.moveSync (C:\actions-runner\_work\_actions\android-actions\setup-android\v2\dist\index.js:1:17775)
    at C:\actions-runner\_work\_actions\android-actions\setup-android\v2\dist\index.js:1:27200
    at Generator.next (<anonymous>)
    at fulfilled (C:\actions-runner\_work\_actions\android-actions\setup-android\v2\dist\index.js:1:25035)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:7028) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7028) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I'm using self-hosted runners so they're not new machine images each time. That's probably why the destination already exists.

@ViliusSutkus89
Copy link
Collaborator

I'm using self-hosted runners so they're not new machine images each time. That's probably why the destination already exists.

This is one of the reasons. I'm more concerned about the realization that the path C:\actions-runner\_work\_temp\351f9f94-7883-436f-a3b7-7f5cbe75c384 is the same on each run. We get it from tool cache's extractZip, which internally does path.join(_getTempDirectory(), uuidV4()). I'm having a hard time believing that uuidV4() gives the same value on each run.

ANDROID_SDK_ROOT is not being set because we errored out 😞

Of course, this could be fixed by properly cleaning up after the extraction, which I haven't done yet 😅 . Could be a one liner, let me see what's possible.

ViliusSutkus89 added a commit to ViliusSutkus89/setup-android that referenced this issue Mar 2, 2021
@ViliusSutkus89
Copy link
Collaborator

Try manually removing C:\actions-runner\_work\_temp\351f9f94-7883-436f-a3b7-7f5cbe75c384 and running the workflow again. Did a release which should remove the folder after extraction.

@AceCoderLaura
Copy link
Contributor Author

Alrighty, I'll give it a try.

@AceCoderLaura
Copy link
Contributor Author

The C:\actions-runner\_work\_temp\ folder was empty. The same error I posted two hours ago occurs when I run the workflow.

@ViliusSutkus89
Copy link
Collaborator

No idea, to be honest. I've just noticed that tool-cache creates dest folder before extracting, so whatever else folder would I give - it would execute the same code path and throw the same exception.

  dest = await _createExtractFolder(dest)

  if (IS_WINDOWS) {
    await extractZipWin(file, dest)
  } ...

Any chance your runner is borked somehow?

@AceCoderLaura
Copy link
Contributor Author

Hmm, I could try reinstalling the runner. I'll do that and report back.

@AceCoderLaura
Copy link
Contributor Author

I reinstalled the runner but the error persists.

@AceCoderLaura
Copy link
Contributor Author

I made a fork and put an exists check around this line:

fse.moveSync(

It's a workaround since it won't replace an outdated copy but it does work now. Might add a proper fix and do a PR if I get the time.

@ViliusSutkus89
Copy link
Collaborator

I was under the impression that the exception was thrown in

const cmdlineToolsExtractedLocation = await tc.extractZip(cmdlineToolsZip)

@ViliusSutkus89
Copy link
Collaborator

The C:\actions-runner_work_temp\ folder was empty. The same error I posted two hours ago occurs when I run the workflow.

My intuition is telling me that the error in you got was a really similar, but not exactly the same.

I'm 80% sure that if (fs.existsSync(desiredLocation)) fse.removeSync(desiredLocation) wouldn't fix the problem, because it's already somewhat accounted for.

function findPreinstalledSdkManager() {
  const result = {isFound: false, isCorrectVersion: false, exePath: ''}
  // exePath is ${ANDROID_SDK_ROOT}/cmdline-tools/3.0/bin/sdkmanager
  result.exePath = getSdkManagerPath(CMDLINE_TOOLS_VERSION)
  result.isFound = fs.existsSync(result.exePath)
  if (result.isFound) {
    result.isCorrectVersion = true
    return result
  }
}
...
const sdkManager = findPreinstalledSdkManager()
if (!sdkManager.isFound) {
...
// desiredLocation is ${ANDROID_SDK_ROOT}/cmdline-tools/3.0
if (fs.existsSync(desiredLocation)) fse.removeSync(desiredLocation)
...
}

That leaves us with a 20% chance of folder ${ANDROID_SDK_ROOT}/cmdline-tools/3.0 existing, but no ${ANDROID_SDK_ROOT}/cmdline-tools/3.0/bin/sdkmanager executable being there.
Only way for this to happen is if we previously tried to move it there, but the move failed half way.
Sure, we could guard against that, but does that actually solve your problem?

Also, do you mind if I squash your PR into a single commit?

@AceCoderLaura
Copy link
Contributor Author

It certainly fixes the issue, I was led to the line from the stack trace.

Feel free to squash the PR.

ViliusSutkus89 pushed a commit that referenced this issue Mar 2, 2021
* Trying this

* Revert "Trying this"

This reverts commit 46eab8f.

* Put exists check around tools move

* Remove directory before copying over it

* Reverted indent

* Revert additional two spaces
@ViliusSutkus89
Copy link
Collaborator

OK, let's see if v2 works now

@AceCoderLaura
Copy link
Contributor Author

v2 works now, cheers 😁

@ViliusSutkus89
Copy link
Collaborator

cool :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants