# Ruby Support on Windows

**URL:** <https://travis-ci.community/t/ruby-support-on-windows/265>\
**Category:** Windows\
**Created:** [October 12, 2018, 2:49am UTC](https://travis-ci.community/t/ruby-support-on-windows/265 "2018-10-12T02:49:56Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashmaroli](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ashmaroli/32/3993_2.png) [@ashmaroli](https://travis-ci.community/u/ashmaroli)\
**Post date:** [October 12, 2018, 2:49am UTC](https://travis-ci.community/t/ruby-support-on-windows/265/1 "2018-10-12T02:49:56Z")

</div>

Hi 👋  
Thank you very much for bringing Windows support to Travis CI.  
I hope Travis adds support for the popular cross-platform language Ruby, as soon as possible.

Even though `ruby` has been listed under the packages at [https://docs.travis-ci.com/user/reference/windows#pre-installed-packages](https://docs.travis-ci.com/user/reference/windows#pre-installed-packages), the build currently fails with following message:

```auto
The language 'ruby' is currently unsupported on the Windows Build Environment.

```

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [October 12, 2018, 11:36am UTC](https://travis-ci.community/t/ruby-support-on-windows/265/2 "2018-10-12T11:36:32Z")

</div>

Hello, there.

Indeed, Ruby 2.5.x _is_ pre-installed via Chocolatey.

The issue here is that, with `language: ruby`, we compile a script to execute the job, but the script will require some additional tooling that is not yet available on the Windows image yet. We will work on that soon.

---

<div class="post-metadata">

**Author:** ![leoarnold](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/leoarnold/32/183_2.png) [@leoarnold](https://travis-ci.community/u/leoarnold)\
**Post date:** [October 14, 2018, 8:54pm UTC](https://travis-ci.community/t/ruby-support-on-windows/265/3 "2018-10-14T20:54:17Z")

</div>

@BanzaiMan is it possible to add a Windows build using the preinstalled Ruby to an existing `language: ruby` Travis configuration? How would I need to adapt?

---

<div class="post-metadata">

**Author:** ![ioquatix](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ioquatix/32/490_2.png) [@ioquatix](https://travis-ci.community/u/ioquatix)\
**Post date:** [November 18, 2018, 9:06pm UTC](https://travis-ci.community/t/ruby-support-on-windows/265/4 "2018-11-18T21:06:26Z")

</div>

How can I avoid this? If I don’t specify any `lang`, it still seems to tell me that error.

Update: I set `language: generic` but now the build just sits there forever, at least it seems like it might work now?

---

<div class="post-metadata">

**Author:** ![jayvdb](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/jayvdb/32/1966_2.png) [@jayvdb](https://travis-ci.community/u/jayvdb)\
**Post date:** [June 18, 2019, 7:09am UTC](https://travis-ci.community/t/ruby-support-on-windows/265/5 "2019-06-18T07:09:32Z")

</div>

Has anyone managed to tweak the pre-installed ruby environment so that can compile gems?

I am using [ruby2.devkit](https://chocolatey.org/packages/ruby2.devkit) , but it requires msys2. I would rather not install either given the problems with using msys.

Here is my latest job [https://travis-ci.org/jayvdb/coala-bears/jobs/547079066](https://travis-ci.org/jayvdb/coala-bears/jobs/547079066)  
(All the choco work is hidden under `powershell -c "fudge install"`)

Even then, I cant install `travis.rb` easily , because it depends on `pusher-client` which depends on `json`, which needs `-lgmp` , and … ouch … I gave up and added `gem "pusher-client", "~>0.4.0"` to my Gemfile because that version doesnt need the `json` gem.

Also I found that adding DevKit to the PATH caused everything to run _extremely_ slowly.  
See the durations of the commands at [https://travis-ci.org/jayvdb/coala-bears/jobs/546698689](https://travis-ci.org/jayvdb/coala-bears/jobs/546698689)

I think I have fixed that by adding the following to the beginning of the job to turn off Windows Defender.

```auto
- powershell -command 'Set-MpPreference -DisableRealtimeMonitoring $true'
- powershell -command 'Set-MpPreference -DisableArchiveScanning $true'
- powershell -command 'Set-MpPreference -DisableBehaviorMonitoring $true'

```

---

<div class="post-metadata">

**Author:** ![jeffreycoe](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/jeffreycoe/32/2051_2.png) [@jeffreycoe](https://travis-ci.community/u/jeffreycoe)\
**Post date:** [June 22, 2019, 3:43pm UTC](https://travis-ci.community/t/ruby-support-on-windows/265/6 "2019-06-22T15:43:18Z")

</div>

I used the following configuration on my Windows build and it completed a bundle install with no errors (I was using the json gem, too):

```bash
- os: windows
  language: bash
  install:
    - choco install mingw
    - choco install msys2
    - ridk.cmd exec pacman -S --noconfirm --needed base-devel mingw-w64-x86_64-toolchain

```

---

<div class="post-metadata">

**Author:** ![jayvdb](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/jayvdb/32/1966_2.png) [@jayvdb](https://travis-ci.community/u/jayvdb)\
**Post date:** [June 25, 2019, 12:47pm UTC](https://travis-ci.community/t/ruby-support-on-windows/265/7 "2019-06-25T12:47:55Z")

</div>

I guess that is not much different to what ruby2.devkit is doing. I was hoping to avoid msys. I wonder why you needed both the choco package mingw and the msys-pacman package mingw-w64-x86\_64-toolchain. I would expect they had similar contents.

---

<div class="post-metadata">

**Author:** ![david942j](https://avatars.discourse-cdn.com/v4/letter/d/59ef9b/32.png) [@david942j](https://travis-ci.community/u/david942j)\
**Post date:** [June 20, 2020, 7:11am UTC](https://travis-ci.community/t/ruby-support-on-windows/265/8 "2020-06-20T07:11:07Z")

</div>

What’s the progress on this? Still seeing this issue today. Wish this can be supported soon 😉

---

<div class="post-metadata">

**Author:** ![andrew-aladev](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/andrew-aladev/32/5486_2.png) [@andrew-aladev](https://travis-ci.community/u/andrew-aladev)\
**Post date:** [November 5, 2020, 10:29pm UTC](https://travis-ci.community/t/ruby-support-on-windows/265/9 "2020-11-05T22:29:35Z")

</div>

There is a problem: ruby from msys2 package was [not configured properly](https://github.com/msys2/MSYS2-packages/issues/2232), this config may be valid for cygwin, but not for mingw. Thats why users have to bring together ruby build for windows by rubyinstaller (unpacked by choco) and msys2.

PS we don’t need to use complete base-devel mingw-w64-x86\_64-toolchain packages, mingw-w64-x86\_64-binutils, mingw-w64-x86\_64-crt-git, mingw-w64-x86\_64-gcc, make will be enough.

Official travis documentation introduced some strange wunderwaffe `export msys2 = ...`, it can be replaced by `ridk.cmd exec`, because we have to deal with rubyinstaller anyway.

```auto
- os: windows
  arch: amd64
  language: bash # using git bash
  before_install:
    - choco uninstall mingw -y
    - choco upgrade msys2 ruby -y
    - ridk.cmd exec pacman --sync --noconfirm --needed
        mingw-w64-x86_64-binutils
        mingw-w64-x86_64-crt-git
        mingw-w64-x86_64-gcc
        make

```

After that you can make `gem install json` with extensions successfully.

Using this simple config I’ve added windows testing for small gem [ocg](https://github.com/andrew-aladev/ocg). Please checkout the [following successful log](https://travis-ci.com/github/andrew-aladev/ocg/jobs/429278857).

---

<div class="post-metadata">

**Author:** ![andrew-aladev](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/andrew-aladev/32/5486_2.png) [@andrew-aladev](https://travis-ci.community/u/andrew-aladev)\
**Post date:** [November 6, 2020, 10:44pm UTC](https://travis-ci.community/t/ruby-support-on-windows/265/10 "2020-11-06T22:44:00Z")

</div>

There is another variant: use `mingw-w64-x86_64-ruby` instead of `ruby` from rubyinstaller and i think it will be much better, it will have less issues with library bindings. In this case we may use wunderwaffe from travis.

```auto
language: ruby

jobs:
  include:
    # other jobs
    - os: windows
      arch: amd64
      language: bash # using git bash
      before_install:
        - |-
          choco uninstall -y mingw ruby
          choco upgrade -y msys2

          export msys2='cmd //C RefreshEnv.cmd '
          export msys2+='& set MSYS=winsymlinks:nativestrict '
          export msys2+='& C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start'
          export mingw64="$msys2 -mingw64 -full-path -here -c "\"\$@"\" --"
          export msys2+=" -msys2 -c "\"\$@"\" --"

          $msys2 pacman --sync --noconfirm --needed \
            mingw-w64-x86_64-binutils \
            mingw-w64-x86_64-crt-git \
            mingw-w64-x86_64-gcc \
            make \
            mingw-w64-x86_64-ruby

before_cache:
  - |-
    if ["$TRAVIS_OS_NAME" == "windows"]; then
      # https://unix.stackexchange.com/a/137322/107554
      $msys2 exec pacman --sync --clean --noconfirm
    fi

cache:
  directories:
    - ${HOME}/AppData/Local/Temp/chocolatey
    - /C/tools

before_install:
  - |-
    if ["$TRAVIS_OS_NAME" == "windows"]; then
      $mingw64 gem install bundler
    else
      gem install bundler
    fi

script:
  - |-
    if ["$TRAVIS_OS_NAME" == "windows"]; then
      $mingw64 scripts/ci_test.sh
    else
      scripts/ci_test.sh
    fi

```

This solution works perfect for me. I will try to implement windows support for some gems using such config.

---

<div class="post-metadata">

**Author:** ![andrew-aladev](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/andrew-aladev/32/5486_2.png) [@andrew-aladev](https://travis-ci.community/u/andrew-aladev)\
**Post date:** [November 7, 2020, 10:58am UTC](https://travis-ci.community/t/ruby-support-on-windows/265/11 "2020-11-07T10:58:52Z")

</div>

First gem with windows (mingw) support is [ocg](https://github.com/andrew-aladev/ocg), you can review travis config and log.

---

<div class="post-metadata">

**Author:** ![tanzislam](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/tanzislam/32/2591_2.png) [@tanzislam](https://travis-ci.community/u/tanzislam)\
**Post date:** [November 8, 2020, 2:11pm UTC](https://travis-ci.community/t/ruby-support-on-windows/265/12 "2020-11-08T14:11:51Z")

</div>

> [@andrew-aladev](#):
>
> Official travis documentation introduced some strange wunderwaffe `export msys2 = ...` , it can be replaced by `ridk.cmd exec` , because we have to deal with rubyinstaller anyway.

`ridk.cmd` seems to be distributed with the Ruby installer. The official Travis guidance on use of MSYS2 needs to be as general as possible, so it can’t depend on that (unless `ridk.cmd` is spun off as an separate project).

> [@andrew-aladev](#):
>
> There is another variant: use `mingw-w64-x86_64-ruby` instead of `ruby` from rubyinstaller and i think it will be much better, it will have less issues with library bindings.

Yes, in general use the packages from [the “mingw64” repo instead of the “msys2” repo](https://packages.msys2.org/repos) when developing Windows applications. This avoids [depending on `msys-2.0.dll`](https://www.msys2.org/wiki/MSYS2-introduction/#subsystems), which (like Cygwin) is only appropriate for POSIX-targeted programs.

---

<div class="post-metadata">

**Author:** ![andrew-aladev](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/andrew-aladev/32/5486_2.png) [@andrew-aladev](https://travis-ci.community/u/andrew-aladev)\
**Post date:** [December 3, 2020, 8:05am UTC](https://travis-ci.community/t/ruby-support-on-windows/265/13 "2020-12-03T08:05:38Z")

</div>

I’ve added windows support for more projects, but I can’t use travis ci anymore, 10000 credits is not enough. I can’t understand travis business model: windows support for ruby projects is not ready yet and marked as experimental, but it is not possible to use it without credits.

Ruby win32 folder has large amount of issues: I’ve found that TCPServer is not thread safe on windows. Now I am moving to appveyor as main ci, I will provide more information on appveyor forums.
