Maher4Ever / wdm

Windows Directory Monitor (WDM) is a threaded directories monitor for Windows.
https://rubygems.org/gems/wdm
MIT License
50 stars 13 forks source link

Gem install on Windows fails on Ruby 3.3.1 due to implicit function declaration #27

Open johnnyshields opened 1 month ago

johnnyshields commented 1 month ago

Issue

On Windows 11, Ruby 3.3.1 using Windows Ruby Installer w/ Devkit, I encountered the following native build issue:

> gem install wdm
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR:  Error installing wdm:
        ERROR: Failed to build gem native extension.

    current directory: C:/ruby33/lib/ruby/gems/3.3.0/gems/wdm-0.1.1/ext/wdm
C:/ruby33/bin/ruby.exe extconf.rb
checking for -lkernel32... yes
checking for windows.h... yes
checking for ruby.h... yes
checking for HAVE_RUBY_ENCODING_H... yes
checking for rb_thread_call_without_gvl()... yes
creating Makefile

current directory: C:/ruby33/lib/ruby/gems/3.3.0/gems/wdm-0.1.1/ext/wdm
make DESTDIR\= sitearchdir\=./.gem.20240516-27944-207rfu sitelibdir\=./.gem.20240516-27944-207rfu clean

current directory: C:/ruby33/lib/ruby/gems/3.3.0/gems/wdm-0.1.1/ext/wdm
make DESTDIR\= sitearchdir\=./.gem.20240516-27944-207rfu sitelibdir\=./.gem.20240516-27944-207rfu
generating wdm_ext-x64-mingw-ucrt.def
compiling entry.c
compiling memory.c
compiling monitor.c
compiling queue.c
compiling rb_change.c
rb_change.c: In function 'extract_absolute_path_from_notification':
rb_change.c:139:5: warning: 'RB_OBJ_TAINT' is deprecated: taintedness turned out to be a wrong idea. [-Wdeprecated-declarations]
  139 |     OBJ_TAINT(path);
      |     ^~~~~~~~~
In file included from C:/ruby33/include/ruby-3.3.0/ruby/internal/core/rstring.h:30,
                 from C:/ruby33/include/ruby-3.3.0/ruby/internal/arithmetic/char.h:29,
                 from C:/ruby33/include/ruby-3.3.0/ruby/internal/arithmetic.h:24,
                 from C:/ruby33/include/ruby-3.3.0/ruby/ruby.h:28,
                 from C:/ruby33/include/ruby-3.3.0/ruby.h:38,
                 from wdm.h:22,
                 from rb_change.c:4:
C:/ruby33/include/ruby-3.3.0/ruby/internal/fl_type.h:824:1: note: declared here
  824 | RB_OBJ_TAINT(VALUE obj)
      | ^~~~~~~~~~~~
compiling rb_monitor.c
rb_monitor.c: In function 'rb_monitor_run_bang':
rb_monitor.c:509:29: error: implicit declaration of function 'rb_thread_call_without_gvl' [-Wimplicit-function-declaration]
  509 |         waiting_succeeded = rb_thread_call_without_gvl(wait_for_changes, monitor->process_event, stop_monitoring, monitor);
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:248: rb_monitor.o] Error 1

make failed, exit code 2

Gem files will remain installed in C:/ruby33/lib/ruby/gems/3.3.0/gems/wdm-0.1.1 for inspection.
Results logged to C:/ruby33/lib/ruby/gems/3.3.0/extensions/x64-mingw-ucrt/3.3.0/wdm-0.1.1/gem_make.out

Workaround

Referring to this similar issue: https://github.com/ffi/ffi/issues/840

I found the following command works:

gem install wdm -- --with-cflags=-Wno-implicit-function-declaration
navdeep-soni commented 1 month ago

Hi,

I tried the workaround suggested but no luck.

gem install wdm -- --with-cflags=-Wno-implicit-function-declaration

Any idea how to resolve this?

P.S: I am on windows 11, Ruby 3.2.4 using Windows Ruby Installer w/ Devkit

johnnyshields commented 1 month ago

@navdeep-soni can you post the log output you see? You many need to run it from a console with admin privileges (right click --> "Run as Administrator")

navdeep-soni commented 1 month ago

Yep,

did it as admin. got it successfully installed but the same error in vscode

Error coming frombundle install`

Command failed with exit code 5: bundle install Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/wdm-0.1.1/ext/wdm C:/Ruby32-x64/bin/ruby.exe extconf.rb checking for -lkernel32... yes checking for windows.h... yes checking for ruby.h... yes checking for HAVE_RUBY_ENCODING_H... yes checking for rb_thread_call_without_gvl()... yes creating Makefile

current directory: C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/wdm-0.1.1/ext/wdm make DESTDIR\= sitearchdir\=./.gem.20240602-24924-6pt381 sitelibdir\=./.gem.20240602-24924-6pt381 clean

current directory: C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/wdm-0.1.1/ext/wdm make DESTDIR\= sitearchdir\=./.gem.20240602-24924-6pt381 sitelibdir\=./.gem.20240602-24924-6pt381 generating wdm_ext-x64-mingw-ucrt.def compiling entry.c compiling memory.c compiling monitor.c compiling queue.c compiling rb_change.c rb_change.c: In function 'extract_absolute_path_from_notification': rb_change.c:139:5: warning: 'RB_OBJ_TAINT' is deprecated: taintedness turned out to be a wrong idea. [-Wdeprecated-declarations] 139 | OBJ_TAINT(path); | ^~~~~ In file included from C:/Ruby32-x64/include/ruby-3.2.0/ruby/internal/core/rstring.h:30, from C:/Ruby32-x64/include/ruby-3.2.0/ruby/internal/arithmetic/char.h:29, from C:/Ruby32-x64/include/ruby-3.2.0/ruby/internal/arithmetic.h:24, from C:/Ruby32-x64/include/ruby-3.2.0/ruby/ruby.h:28, from C:/Ruby32-x64/include/ruby-3.2.0/ruby.h:38, from wdm.h:22, from rb_change.c:4: C:/Ruby32-x64/include/ruby-3.2.0/ruby/internal/fl_type.h:116:30: note: declared here 116 | #define RB_OBJ_TAINT RB_OBJ_TAINT | ^~~~ C:/Ruby32-x64/include/ruby-3.2.0/ruby/internal/fl_type.h:852:1: note: in expansion of macro 'RB_OBJ_TAINT' 852 | RB_OBJ_TAINT(VALUE obj) | ^~~~ compiling rb_monitor.c rb_monitor.c: In function 'rb_monitor_run_bang': rb_monitor.c:509:29: error: implicit declaration of function 'rb_thread_call_without_gvl' [-Wimplicit-function-declaration] 509 | waiting_succeeded = rb_thread_call_without_gvl(wait_for_changes, monitor->process_event, stop_monitoring, monitor); | ^~~~~~ make: *** [Makefile:248: rb_monitor.o] Error 1

make failed, exit code 2

Gem files will remain installed in C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/wdm-0.1.1 for inspection. Results logged to C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/extensions/x64-mingw-ucrt/3.2.0/wdm-0.1.1/gem_make.out

C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:125:in run' C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:51:inblock in make' C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:43:in each' C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:43:inmake' C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/ext/ext_conf_builder.rb:42:in build' C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:193:in build_extension' C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:227:in block in build_extensions' C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:224:ineach' C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:224:in build_extensions' C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/installer.rb:852:in build_extensions' C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/rubygems_gem_installer.rb:72:in build_extensions' C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/rubygems_gem_installer.rb:28:in install' C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/source/rubygems.rb:207:in install' C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/installer/gem_installer.rb:54:in install' C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/installer/gem_installer.rb:16:in install_from_spec' C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/installer/parallel_installer.rb:186:in do_install' C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/installer/parallel_installer.rb:177:in block in worker_pool' C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/worker.rb:62:in apply_func' C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/worker.rb:57:in block in process_queue' C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/worker.rb:54:in loop' C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/worker.rb:54:in process_queue' C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/worker.rb:91:in block (2 levels) in create_threads'

An error occurred while installing wdm (0.1.1), and Bundler cannot continue.

In Gemfile: wdm Fetching gem metadata from https://rubygems.org/........... Resolving dependencies... Using bundler 2.3.20 Using concurrent-ruby 1.1.10 Using ffi 1.15.4 Using rb-fsevent 0.11.1 Using bugsnag 6.24.2 Using rb-inotify 0.10.1 Using listen 3.7.1 Installing wdm 0.1.1 with native extensions Screenshot 2024-06-02 094154 `

johnnyshields commented 1 month ago

@navdeep-soni the problem is that you are running gem install and installing it successfully to your Ruby install dir gems. Next when you run bundle install, you are freshly installing the gem to a cache directory under /Shopify/…. This fails because —with-cflags param is not being applied during the bundle install.

A workaround would be (a) to use non-vendored gems in your project or (b) to gem install to the cache dir with the correct cflags arg. If this doesnt make sense, please seek help in a Ruby forum or ask ChatGPT.

navdeep-soni commented 1 month ago

thanks for looking into it

I tried using this

gem install wdm -v '0.1.1' --install-dir C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0 -- --with-cflags="-O2 -pipe"

and got error again

gem install wdm -v '0.1.1' --install-dir C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0 -- --with-cflags="-O2 -pipe" Temporarily enhancing PATH for MSYS/MINGW... Building native extensions with: '--with-cflags=-O2 -pipe' This could take a while... ERROR: Error installing wdm: ERROR: Failed to build gem native extension.

current directory: C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/wdm-0.1.1/ext/wdm

C:/Ruby32-x64/bin/ruby.exe extconf.rb --with-cflags\=-O2\ -pipe checking for -lkernel32... yes checking for windows.h... yes checking for ruby.h... yes checking for HAVE_RUBY_ENCODING_H... yes checking for rb_thread_call_without_gvl()... yes creating Makefile

current directory: C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/wdm-0.1.1/ext/wdm make DESTDIR\= sitearchdir\=./.gem.20240602-28864-mqcflf sitelibdir\=./.gem.20240602-28864-mqcflf clean

current directory: C:/Users/navdeep/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/wdm-0.1.1/ext/wdm make DESTDIR\= sitearchdir\=./.gem.20240602-28864-mqcflf sitelibdir\=./.gem.20240602-28864-mqcflf generating wdm_ext-x64-mingw-ucrt.def compiling entry.c compiling memory.c compiling monitor.c compiling queue.c compiling rb_change.c rb_change.c: In function 'extract_absolute_path_from_notification': rb_change.c:139:5: warning: 'RB_OBJ_TAINT' is deprecated: taintedness turned out to be a wrong idea. [-Wdeprecated-declarations] 139 | OBJ_TAINT(path); | ^~~~~ In file included from C:/Ruby32-x64/include/ruby-3.2.0/ruby/internal/core/rstring.h:30, from C:/Ruby32-x64/include/ruby-3.2.0/ruby/internal/arithmetic/char.h:29, from C:/Ruby32-x64/include/ruby-3.2.0/ruby/internal/arithmetic.h:24, from C:/Ruby32-x64/include/ruby-3.2.0/ruby/ruby.h:28, from C:/Ruby32-x64/include/ruby-3.2.0/ruby.h:38, from wdm.h:22, from rb_change.c:4: C:/Ruby32-x64/include/ruby-3.2.0/ruby/internal/fl_type.h:116:30: note: declared here 116 | #define RB_OBJ_TAINT RB_OBJ_TAINT | ^~~~ C:/Ruby32-x64/include/ruby-3.2.0/ruby/internal/fl_type.h:852:1: note: in expansion of macro 'RB_OBJ_TAINT' 852 | RB_OBJ_TAINT(VALUE obj) | ^~~~ compiling rb_monitor.c rb_monitor.c: In function 'rb_monitor_run_bang': rb_monitor.c:509:29: error: implicit declaration of function 'rb_thread_call_without_gvl' [-Wimplicit-function-declaration] 509 | waiting_succeeded = rb_thread_call_without_gvl(wait_for_changes, monitor->process_event, stop_monitoring, monitor); | ^~~~~~ make: *** [Makefile:248: rb_monitor.o] Error 1

make failed, exit code 2

where should I look for non-vendored gem for wdm

johnnyshields commented 1 month ago

Please ask in a different forum, thanks.

johnresearches commented 3 weeks ago

I faced the same issue, and I did the following to get out of my ruby problem. If this works for you, mark my post as the solution/answer for others to benefit. I employed this solution on a Windows machine.

gem install wdm --platform=ruby
navdeep-soni commented 3 weeks ago

this one worked for me.

https://stackoverflow.com/a/78617137/23467046

also in this version (Ruby+Devkit 3.1.2-1 (x64), I additionally searched the entire c:\ drive for any gems/ruby/wdm/ff

szschaler commented 2 weeks ago

Actually, the problem here appears to be that object tainting was deprecated in Ruby a long time ago and has now been removed. As a result, the WDM code doesn't compile anymore with recent Ruby versions.

I believe, but don't understand object tainting well enough to be sure, that simply removing the offending statements (possibly subject to a check of Ruby version) would fix this. This is a fix that's needed inside WDM code.

TaheerAhmed commented 1 week ago

This one worked for me go to ruby and install this particular version 100% solves the issue wasted 8hrs till I found this solution https://github.com/Maher4Ever/wdm/issues/27#issuecomment-2171037041