Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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

Solved

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

kurs
Shopify Partner
12 0 1

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?

Accepted Solution (1)

Bigside_Tech
Shopify Partner
16 2 22

This is an accepted solution.

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 🙂

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store or solve an issue, please send me a personal message and we can discuss what you'd like to accomplish.

View solution in original post

Replies 19 (19)

Bigside_Tech
Shopify Partner
16 2 22

Same with me for shopify theme dev. Any help?

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store or solve an issue, please send me a personal message and we can discuss what you'd like to accomplish.

Bigside_Tech
Shopify Partner
16 2 22

This is an accepted solution.

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 🙂

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store or solve an issue, please send me a personal message and we can discuss what you'd like to accomplish.
smush1
Shopify Partner
7 0 3

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

Bigside_Tech
Shopify Partner
16 2 22

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

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store or solve an issue, please send me a personal message and we can discuss what you'd like to accomplish.
joshy123
Shopify Partner
2 0 1

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).

Bigside_Tech
Shopify Partner
16 2 22

Agreed! it was frustrating. Glad it helped 🙂

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store or solve an issue, please send me a personal message and we can discuss what you'd like to accomplish.
dukalis2004
Shopify Partner
1 0 0

Cool! It's finally working!

 

Thanks for your solution!

Bigside_Tech
Shopify Partner
16 2 22

You're welcome 🙂

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store or solve an issue, please send me a personal message and we can discuss what you'd like to accomplish.
DMZS
Shopify Partner
2 0 0

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

Bigside_Tech
Shopify Partner
16 2 22

Yes, it was all about that specific ruby version 🙂

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store or solve an issue, please send me a personal message and we can discuss what you'd like to accomplish.
Tayyabulislam
Shopify Partner
1 0 0

This worked for me, Thanks

Bigside_Tech
Shopify Partner
16 2 22

Glad it helped 🙂

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store or solve an issue, please send me a personal message and we can discuss what you'd like to accomplish.
WBG
Shopify Partner
6 1 6

@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)

Bigside_Tech
Shopify Partner
16 2 22

Glad it helped!

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store or solve an issue, please send me a personal message and we can discuss what you'd like to accomplish.
DevJoest
Tourist
3 0 9

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

Thanks @Bigside_Tech 

Bigside_Tech
Shopify Partner
16 2 22

You're welcome 🙂

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store or solve an issue, please send me a personal message and we can discuss what you'd like to accomplish.
jpdev
Shopify Partner
2 0 0

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-sing...

Bigside_Tech
Shopify Partner
16 2 22

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

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store or solve an issue, please send me a personal message and we can discuss what you'd like to accomplish.
Sello_2k
Shopify Partner
10 0 1

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