"Error: Failed to build gem native extension" after shopify app dev command

After updating Shopify CLI version I have a problem with “shopify app dev” command. This is an error message:

"Error coming from bundle install

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

current directory: C:/Users/CognitionHub
IT/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/ffi-1.15.4/ext/ffi_c
C:/Ruby32-x64/bin/ruby.exe extconf.rb
checking for ffi.h… no
checking for ffi.h in
/usr/local/include,/usr/include/ffi,/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi,/Applications/Xc
ode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ffi…
no
checking for whether -Wl,–exclude-libs,ALL is accepted as LDFLAGS… yes
checking for whether -pthread is accepted as LDFLAGS… yes
creating extconf.h
creating Makefile

current directory: C:/Users/CognitionHub
IT/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/ffi-1.15.4/ext/ffi_c
make DESTDIR= sitearchdir=./.gem.20240417-3588-neomcd
sitelibdir=./.gem.20240417-3588-neomcd clean

current directory: C:/Users/CognitionHub
IT/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/ffi-1.15.4/ext/ffi_c
make DESTDIR= sitearchdir=./.gem.20240417-3588-neomcd
sitelibdir=./.gem.20240417-3588-neomcd
generating ffi_c-x64-mingw-ucrt.def
/bin/sh: -c: linia 1: błąd składni przy nieoczekiwanym znaczniku (' /bin/sh: -c: linia 1: mkdir -p “/c/Users/CognitionHub
IT/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/ffi-1.15.4/ext/ffi_c/libffi-x64-mingw-ucrt”
“”/c/Users/CognitionHub(D)"’
make: *** [libffi.mk:6: "/c/Users/CognitionHub] Błąd 2

make failed, exit code 2

Gem files will remain installed in C:/Users/CognitionHub
IT/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/ffi-1.15.4 for
inspection.
Results logged to C:/Users/CognitionHub
IT/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/extensions/x64-mingw-ucrt/3.2.0/ffi-1.15.4/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:in block 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:in make’
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:in each’
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/CognitionHub
IT/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/CognitionHub IT/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/CognitionHub
IT/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/CognitionHub IT/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/CognitionHub
IT/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/CognitionHub IT/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/installer/parallel_installer.rb:18 6:in do_install’
C:/Users/CognitionHub
IT/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/installer/parallel_installer.rb:17
7:in
block in worker_pool' C:/Users/CognitionHub IT/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/CognitionHub
IT/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/CognitionHub IT/AppData/Local/shopify-gems-nodejs/Cache/ruby/3.2.0/gems/bundler-2.3.20/lib/bundler/worker.rb:54:in loop’
C:/Users/CognitionHub
IT/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/CognitionHub IT/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 ffi (1.15.4), and Bundler cannot continue.

In Gemfile:
listen was resolved to 3.7.1, which depends on
rb-inotify was resolved to 0.10.1, which depends on
ffi
Fetching gem metadata from https://rubygems.org/
Resolving dependencies…
Using bundler 2.3.20
Using concurrent-ruby 1.1.10
Using rb-fsevent 0.11.1
Using wdm 0.1.1
Using bugsnag 6.24.2
Installing ffi 1.15.4 with native extensions"

Can it be caussed by uncompatibile ruby version?

Same with me for shopify theme dev. Any help?

I got it working finally (for windows). Here are the steps I followed. It might help someone.

  1. from ruby downloads (https://rubyinstaller.org/downloads/)) , I installed 3.0 version specifically as doc says: Ruby+Devkit 3.0.6-1 (x64)
  2. Installed the above ruby with all the options.
  3. Opened command prompt and ran this command (after all ruby installations): ridk enable
  4. Closed Visual Studio code and opened back with administrator permission (press windows icon > search vs code > right click > run as administrator)
  5. Opened respective project and ran: shopify theme dev (got another bundler version error)
  6. Ran following command: gem install bundler
  7. Then ran: shopify theme dev

And it worked :slightly_smiling_face:

Thank you so much. I was searching it for an hour (for windows) and finally your solution is lifesaver.

@smush1 glad it helped. It took me 3-4 hours to get it right :grinning_face_with_smiling_eyes:

Thanks for this solution! I had the latest cli, ruby, and node installed and it was still giving me that error message. With your solution, everything worked!

Sucks we have to spend hours trying to get our machines to install and get the setup working. Things shouldn’t be this difficult (even for a developer).

Agreed! it was frustrating. Glad it helped :slightly_smiling_face:

Cool! It’s finally working!

Thanks for your solution!

You’re welcome :slightly_smiling_face:

I’ve been using latest versions of the tech stacks, and it didn’t work for me.

I’ve been trying higher and lower version combinations, and no luck to get it to work, until I stumbled on your post. So that’s it!

This particular RUBY version worked well for me without issue.

Thank you so much for sharing. It’s been like 4 days of searching for me.

Here’s the versions I have when I saw your post. I will test this as well with Node’s latest version.

node - v18.20.3 (latest is v22.3.0)
shopify cli - 3.62.0 (latest)

npm - 10.8.1 (latest)
git - git version 2.45.2.windows.1 (latest)
ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x64-mingw32]
gem - 3.5.11 (latest)

as of the date/time of reply

Latest Ruby version: 3.3.3-1-x64

Working Ruby version: 3.0.6p216

This worked for me, Thanks

@Bigside_Tech - Thank you for sharing your solution. I was able to proceed with shopify theme dev because of your suggestion.
This worked for me with the below versions of tools with no admin rights.

I also ensured that all folders with ruby, gem, shopify has been deleted, before reinstalling the version of RUBY that works for me.

node - v18.20.3 (latest is v22.3.0)
shopify cli - 3.62.0 (latest)
npm - 10.7.0 (latest is 10.8.1)
git - 2.45.2.windows.1 (latest)
ruby - Ruby+Devkit 3.0.6-1 (x64) (Latest is Ruby+Devkit 3.3.3-1 (x64) )
gem - 3.2.33 (latest is 3.5.11)

After trying various versions of Ruby and a lot of trouble shooting this answer actually worked for me.

Thanks @Bigside_Tech

Yes, it was all about that specific ruby version :slightly_smiling_face:

Glad it helped :slightly_smiling_face:

Glad it helped!

You’re welcome :slightly_smiling_face:

Thank you very much this answer helped me solve it combined with this other:

https://community.shopify.com/c/forums/forumtopicprintpage/board-id/tools/message-id/4484/print-single-message/true/page/1

Thanks, @jpdev for sharing the corresponding link and glad it helped :slightly_smiling_face:

Thank you so much, it worked after your steps.
It was so frustrating…