fastlane / packaged-fastlane

Preparing a Ruby bundle

Home Page:https://fastlane.tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fastlane update_fastlane fails because of native extensions building failure

0xced opened this issue · comments

Documenting how I resolved this issue if anyone else also stumbles on it.

I just tried to run fastlane update_fastlane and it failed with this error:

Updating installed gems
Updating fastlane
Building native extensions.  This could take a while...
Gems updated: msgpack
Gems already up-to-date: fastlane
ERROR:  Error installing fastlane:
	ERROR: Failed to build gem native extension.

    current directory: ~/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/msgpack-1.2.4/ext/msgpack
~/.fastlane/bin/bundle/bin/ruby -r ./siteconf20181012-30133-1kxu5zj.rb extconf.rb
checking for ruby/st.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=~/.fastlane/bin/bundle/bin/$(RUBY_BASE_NAME)
~/.fastlane/bin/bundle/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
	from ~/.fastlane/bin/bundle/lib/ruby/2.2.0/mkmf.rb:587:in `try_cpp'
	from ~/.fastlane/bin/bundle/lib/ruby/2.2.0/mkmf.rb:1060:in `block in have_header'
	from ~/.fastlane/bin/bundle/lib/ruby/2.2.0/mkmf.rb:911:in `block in checking_for'
	from ~/.fastlane/bin/bundle/lib/ruby/2.2.0/mkmf.rb:351:in `block (2 levels) in postpone'
	from ~/.fastlane/bin/bundle/lib/ruby/2.2.0/mkmf.rb:321:in `open'
	from ~/.fastlane/bin/bundle/lib/ruby/2.2.0/mkmf.rb:351:in `block in postpone'
	from ~/.fastlane/bin/bundle/lib/ruby/2.2.0/mkmf.rb:321:in `open'
	from ~/.fastlane/bin/bundle/lib/ruby/2.2.0/mkmf.rb:347:in `postpone'
	from ~/.fastlane/bin/bundle/lib/ruby/2.2.0/mkmf.rb:910:in `checking_for'
	from ~/.fastlane/bin/bundle/lib/ruby/2.2.0/mkmf.rb:1059:in `have_header'
	from extconf.rb:3:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  ~/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/msgpack-1.2.4/mkmf.log

extconf failed, exit code 1

Looking the mkmf.log file reveals the issue:

clang: warning: no such sysroot directory: '/Applications/Xcode-7.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk' [-Wmissing-sysroot]

This /Applications/Xcode-7.3.1.app path comes from ~/.fastlane/bin/bundle/lib/ruby/2.2.0/x86_64-darwin15/rbconfig.rb

After replacing the two occurrences of /Applications/Xcode-7.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk in the rbconfig.rb file with /Applications/Xcode/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk (notice I also replaced MacOSX10.11.sdk with MacOSX.sdk) I got another error (mkmf.log):

"/usr/bin/clang -o conftest -I~/.fastlane/bin/bundle/include/ruby-2.2.0/x86_64-darwin15 -I~/.fastlane/bin/bundle/include/ruby-2.2.0/ruby/backward -I~/.fastlane/bin/bundle/include/ruby-2.2.0 -I. -I/Users/crashlytics/buildAgent/work/2484be8b71880c21/bundle-2.28.3/fastlane_lib/dependencies/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -mmacosx-version-min=10.10 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -pipe conftest.c  -L. -L~/.fastlane/bin/bundle/lib -L. -L/Users/crashlytics/buildAgent/work/2484be8b71880c21/bundle-2.28.3/fastlane_lib/dependencies/lib -fstack-protector     -lruby-static -framework CoreFoundation  -lpthread -ldl -lobjc "
ld: warning: directory not found for option '-L/Users/crashlytics/buildAgent/work/2484be8b71880c21/bundle-2.28.3/fastlane_lib/dependencies/lib'
ld: library not found for -lruby-static
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:   
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

So I deleted -I/Users/crashlytics/buildAgent/work/2484be8b71880c21/bundle-2.28.3/fastlane_lib/dependencies/include in the rbconfig.rb file (CONFIG["CPPFLAGS"] line) and I deleted -L/Users/crashlytics/buildAgent/work/2484be8b71880c21/bundle-2.28.3/fastlane_lib/dependencies/lib (CONFIG["LDFLAGS"] line) and tried again.

Then the next error was this (it was actually already in the previous error but I missed it):

"/usr/bin/clang -o conftest -I~/.fastlane/bin/bundle/include/ruby-2.2.0/x86_64-darwin15 -I~/.fastlane/bin/bundle/include/ruby-2.2.0/ruby/backward -I~/.fastlane/bin/bundle/include/ruby-2.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -mmacosx-version-min=10.10 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -pipe conftest.c  -L. -L~/.fastlane/bin/bundle/lib -L. -fstack-protector     -lruby-static -framework CoreFoundation  -lpthread -ldl -lobjc "
ld: library not found for -lruby-static
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

So I edited rbconfig.rb again and replaced CONFIG["LIBRUBYARG"] = "$(LIBRUBYARG_STATIC)" with CONFIG["LIBRUBYARG"] = ""

Finally, I was able to update my packaged fastlane with fastlane update_fastlane and the native extensions were built successfully. 🎉

Thanks for this @0xced, @joshdholtz is working on a fix