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

bundle install get stuck for a specific gem under setup-ruby action + windows + ruby 2.6 #218

Closed
ntkme opened this issue Sep 20, 2021 · 7 comments

Comments

@ntkme
Copy link
Contributor

ntkme commented Sep 20, 2021

Although I have "a specific gem" in the title, but it does not appear to be the root cause of this problem. So, please bear with me for the details.

Here is a repository for reproduction: https://github.com/ntkme/debug-setup-ruby/blob/main/.github/workflows/build.yml

This is a matrix build:

     matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]
        ruby-version: ['2.6', '2.7', '3.0']

The failed workflow result is here: https://github.com/ntkme/debug-setup-ruby/runs/3648601998?check_suite_focus=true

Every thing other than windows + ruby 2.6 passed really quick. I killed the windows + ruby 2.6 after 15 min, but in reality it get stuck forever and would get killed after 6 hours by GitHub actions.

What works and what doesn't

bundler-cache cache-version os ruby dependency (sass-embedded) works?
true 0 macos 3.0 yes yes
true 0 ubuntu 3.0 yes yes
true 0 windows 3.0 yes yes
true 0 macos 2.7 yes yes
true 0 ubuntu 2.7 yes yes
true 0 windows 2.7 yes yes
true 0 macos 2.6 yes yes
true 0 ubuntu 2.6 yes yes
true 0 windows 2.6 yes stuck forever 1
true 1 windows 2.6 yes stuck forever 2
true 0 windows 2.6 no yes 3
false 0 windows 2.6 yes yes 4
  1. The default matrix works for all combination except for windows + ruby 2.6.
  2. Attempt to use a different cache-version does not fix the problem so it is not a cache corruption issue.
  3. Remove dependency sass-embedded works. - However, this does not appear to be the root cause.
  4. If I copy the bundle commands from the log of failed build and run them as a separate step, It works. This shows there is something weird going on with setup-ruby causing the failure. See below.

This is a diff showing the how I moved the bundle commands out of the ruby-setup action:

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e368543..0f274e6 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -20,4 +20,11 @@ jobs:
       uses: ruby/setup-ruby@v1
       with:
         ruby-version: ${{ matrix.ruby-version }}
-        bundler-cache: true
+        bundler-cache: ${{ matrix.os != 'windows-latest' || matrix.ruby-version != '2.6' }}
+
+    - name: Bundle install
+      if: ${{ matrix.os == 'windows-latest' && matrix.ruby-version == '2.6' }}
+      run: |-
+        C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\Ruby\2.6.8\x64\bin\bundle.bat config --local path D:\a\debug-setup-ruby\debug-setup-ruby\vendor\bundle"
+        C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\Ruby\2.6.8\x64\bin\bundle.bat lock"
+        C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\Ruby\2.6.8\x64\bin\bundle.bat install --jobs 4"

This build shows that running exactly the same bundle commands outside of setup-ruby works: https://github.com/ntkme/debug-setup-ruby/runs/3648668586?check_suite_focus=true


What I need help understanding is that - what is the difference running bundle commands inside setup-ruby action and running exactly same command as a separate step, and why setup-ruby action might cause bundle to stuck forever.

Thanks.

@MSP-Greg
Copy link
Collaborator

@ntkme

Sorry, I've been busy this morning. Is this working as expected using Ruby 2.7 and 3.0?

@ntkme
Copy link
Contributor Author

ntkme commented Sep 20, 2021

@MSP-Greg Yes, you can see from here: https://github.com/ntkme/debug-setup-ruby/runs/3648601998?check_suite_focus=true

2.7 and 3.0 works under windows, ubuntu, and macos. 2.6 works for ubuntu and macos.

@ntkme
Copy link
Contributor Author

ntkme commented Sep 20, 2021

The most strange part as I posted originally is that: if I copy the bundle commands printed by the setup-ruby actions, disable bundle-cache, and just run them in a different step, it would work under windows + ruby 2.6. Meanwhile, it is not a cache corruption as update cache-version does not work.

@MSP-Greg
Copy link
Collaborator

MSP-Greg commented Sep 20, 2021

I repo'd the issue locally. I haven't had time to debug (and may not for a while), but in the ext/sass folder, 2.6 downloaded the zip files, but did not extracted them. Ruby 2.7, 3.0, and master all successfully installed, and all of their folders had the zip files extracted.

Maybe that helps...

@ntkme
Copy link
Contributor Author

ntkme commented Sep 21, 2021

That did help. I managed to get a windows machine to test this and the root cause is insane.

It has to do with running cmd.exe /c del /f /q /s filename from Makefile.

Even after finding the root cause I still don't understand what kind of interpretation difference is happening causing the different behavior of different ruby versions, but apparently under windows ruby 2.6 (maybe due to the old gnu make it bundles), cmd.exe /c del /f /q /s turns out to be interpreted just as cmd.exe and all the arguments are magically getting ignored. Without the arguments, cmd.exe will hang there waiting for user input thus causing gem install to hang.

I did find a workaround that works for ruby 2.6 inside the Makefile: powershell -c "cmd.exe /c del /f /q /s" filename.

@ntkme ntkme closed this as completed Sep 21, 2021
@ashmaroli
Copy link

apparently under windows ruby 2.6 (maybe due to the old gnu make it bundles), cmd.exe /c del /f /q /s turns out to be interpreted just as cmd.exe and all the arguments are magically getting ignored.

@larskanis Hello, is this something that could be addressed by RubyInstaller..?

@MSP-Greg
Copy link
Collaborator

maybe due to the old gnu make it bundles

GitHub Actions and my local system use one set of MSYS2 built tools. So, both in Actions and locally, the passing Ruby versions use the exact same set of MSYS2 tools as Ruby 2.6.

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

No branches or pull requests

3 participants