简体   繁体   中英

How to fix ' Failed to build gem native extension' error with bootsnap with Windows

I am using Windows, and I just installed Ruby on Rails, ruby is version 2.6.3p62 (2019-04-16 revision 67580) [x64-mingw32], rails is version 6.0.0. When running rails new blog (following this tutorial ) bundle install runs.

I have tried reinstalling Ruby, changing its version, and even removing bootsnap and running something else, but even when trying to install the puma gem I get the same error.

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
C:/Ruby26-x64/bin/ruby.exe -I C:/Ruby26-x64/lib/ruby/2.6.0 -r
./siteconf20191028-6188-1rw29js.rb extconf.rb
creating Makefile

current directory:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
make "DESTDIR=" clean

current directory:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
make "DESTDIR="
generating bootsnap-x64-mingw32.def
compiling bootsnap.c
linking shared-object bootsnap/bootsnap.so
C:/Ruby26-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
bootsnap.o:bootsnap.c:(.text+0x557): undefined reference to `__strcat_chk'
C:/Ruby26-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
bootsnap.o:bootsnap.c:(.text+0xa07): undefined reference to `__chk_fail'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:261: bootsnap.so] Error 1

make failed, exit code 2

Gem files will remain installed in
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5 for inspection.
Results logged to
C:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/bootsnap-1.4.5/gem_make.out

An error occurred while installing bootsnap (1.4.5), and Bundler cannot
continue.
Make sure that `gem install bootsnap -v '1.4.5' --source
'https://rubygems.org/'` succeeds before bundling.

Actually, Bootsnap won't work on Windows anyway, so I'd recommend just removing it from Gemfile. If you want to leave it for production environment, perhaps you should include it conditionally with something like:

gem 'bootsnap' unless (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM