Few people may compile mruby on Cygwin,
but here are memos for mruby-4.0.0 and After mruby-4.0.0.
Install gcc, ruby, gem and git via Cygwin setup.
Install rake with gem install rake.
Use hal-posix-*.c files.
--- build_config/default.rb~ 2026-04-20 17:43:06.000000000 +0900
+++ build_config/default.rb 2026-04-26 17:46:09.895058800 +0900
@@ -9,6 +9,9 @@
# end
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
# conf.gem :core => 'mruby-eval'
+ conf.gem :core => 'hal-posix-io'
+ conf.gem :core => 'hal-posix-socket'
+ conf.gem :core => 'hal-posix-dir'
# conf.gem :mgem => 'mruby-onig-regexp'
# conf.gem :github => 'mattn/mruby-onig-regexp'
# conf.gem :git => 'git@github.com:mattn/mruby-onig-regexp.git', :branch => 'master', :options => '-v'tar xf mruby-4.0.0.tar.gz
cd xf mruby-4.0.0
# Apply the patch above.
SERIAL=1 rake
rake testFor Cygwin, Build#effective_ports in mruby/lib/mruby/build.rb should return ['posix'].
With this patch, I can rake test:run:serial.
--- a/lib/mruby/build.rb
+++ b/lib/mruby/build.rb
@@ -201,7 +201,11 @@ module MRuby
[]
elsif ENV['OS'] == 'Windows_NT' ||
('A'..'Z').any? { |v| Dir.exist?("#{v}:") }
- ['win']
+ if RUBY_PLATFORM.include?("cygwin")
+ ['posix']
+ else
+ ['win']
+ end
else
['posix']
end
この変更を Fork https://github.com/t-nissie/mruby に施して、 GitHub ActionsでCygwinでのbuild & testをやろうとしたが、 おそらくCygwinのrubygemsまたはruby-rake pacageでインストールされるgemまたはrakeが静かに0を返しつつも動かない https://github.com/t-nissie/mruby/actions/runs/25100118602/job/73546831865 のでプルリクするわけにもいかず。
Here, I compiled mruby-4.0.0 and mruby from its repository on Cygwin. Maybe, we should use Posix things for Cygwin.
On Cygwin, I can run tests of
- DSL example https://gist.github.com/t-nissie/8b0ebccab3fe41ada28ea0e7fb0b6c23
- mrubybind https://gist.github.com/t-nissie/a2eeabc18c4cd5b010f89890ff30dc5f
My rutine:
cd mruby/mruby/mruby
CC=gcc rake -m test:run:serial
pushd ../../t-nissie.mrubybind/test/; make clean; MRUBY=../../mruby/mruby make -j22 test
pushd ../../constantv; make clean && make && ./v10.constantv abc def