ashfurrow / danger-ruby-swiftlint

A Danger plugin for SwiftLint.
https://rubygems.org/gems/danger-swiftlint
MIT License
203 stars 81 forks source link

Error: Failed to build gem native extension #73

Closed dzenbot closed 6 years ago

dzenbot commented 6 years ago

Since https://github.com/ashfurrow/danger-swiftlint/pull/55 got merged and new versions have been release, we haven't been able to upgrade. Whatever new version of danger-swiftlint is released, we keep getting a Gem::Ext::BuildError: ERROR: Failed to build gem native extension. on the CI.

Any version after 0.8.0 is failing for us.

Any help would be greatly appreciated!

This is my Gemfile:

source "https://rubygems.org"

gem 'danger', '~> 5.2'
gem 'danger-swiftlint', '~> 0.10'
gem 'danger-xcov', '~> 0.3.3'
gem 'xcov', '~> 1.3.0'

And the CI logs (buddybuild):

=== Danger! ===

Installing bundler

Using Command Line: gem install "bundler" --no-rdoc --no-ri

Successfully installed bundler-1.16.0

1 gem installed

Installing Danger

Using Command Line: bundle install

Fetching gem metadata from https://rubygems.org/........

Fetching rake 12.2.1

Installing rake 12.2.1

Fetching CFPropertyList 2.3.5

Installing CFPropertyList 2.3.5

Fetching public_suffix 2.0.5

Installing public_suffix 2.0.5

Fetching addressable 2.5.1

Installing addressable 2.5.1

Fetching babosa 1.0.2

Installing babosa 1.0.2

Using bundler 1.16.0

Fetching claide 1.0.2

Installing claide 1.0.2

Fetching colored2 3.1.2

Installing colored2 3.1.2

Fetching cork 0.3.0

Installing cork 0.3.0

Fetching nap 1.1.0

Installing nap 1.1.0

Fetching open4 1.3.4

Installing open4 1.3.4

Fetching claide-plugins 0.9.2

Installing claide-plugins 0.9.2

Fetching colored 1.2

Installing colored 1.2

Fetching highline 1.7.8

Installing highline 1.7.8

Fetching commander-fastlane 4.4.5

Installing commander-fastlane 4.4.5

Fetching multipart-post 2.0.0

Installing multipart-post 2.0.0

Fetching faraday 0.12.2

Installing faraday 0.12.2

Fetching faraday-http-cache 1.3.1

Installing faraday-http-cache 1.3.1

Fetching git 1.3.0

Installing git 1.3.0

Fetching kramdown 1.14.0

Installing kramdown 1.14.0

Fetching sawyer 0.8.1

Installing sawyer 0.8.1

Fetching octokit 4.7.0

Installing octokit 4.7.0

Fetching unicode-display_width 1.3.0

Installing unicode-display_width 1.3.0

Fetching terminal-table 1.8.0

Installing terminal-table 1.8.0

Fetching danger 5.3.4

Installing danger 5.3.4

Fetching thor 0.20.0

Installing thor 0.20.0

Fetching danger-swiftlint 0.11.0

Installing danger-swiftlint 0.11.0 with native extensions

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

/Users/buddybuild/.rubies/ruby-2.2.5/bin/ruby -rubygems

/tmp/sandbox/workspace/vendor/bundle/ruby/2.2.0/gems/rake-12.2.1/exe/rake

RUBYARCHDIR=/tmp/sandbox/workspace/vendor/bundle/ruby/2.2.0/extensions/x86_64-darwin-16/2.2.0-static/danger-swiftlint-0.11.0

RUBYLIBDIR=/tmp/sandbox/workspace/vendor/bundle/ruby/2.2.0/extensions/x86_64-darwin-16/2.2.0-static/danger-swiftlint-0.11.0

mkdir -p

/private/tmp/sandbox/workspace/vendor/bundle/ruby/2.2.0/gems/danger-swiftlint-0.11.0/ext/swiftlint/bin

&& curl -s -L

https://github.com/realm/SwiftLint/releases/download/<SWIFTLINT_VERSION redacted>/portable_swiftlint.zip

-o portable_swiftlint.zip && unzip -q portable_swiftlint.zip -d

/private/tmp/sandbox/workspace/vendor/bundle/ruby/2.2.0/gems/danger-swiftlint-0.11.0/ext/swiftlint/bin

&& rm portable_swiftlint.zip

Downloading swiftlint@<SWIFTLINT_VERSION redacted>

[portable_swiftlint.zip]

  End-of-central-directory signature not found.  Either this file is not

  a zipfile, or it constitutes one disk of a multi-part archive.  In the

  latter case the central directory and zipfile comment will be found on

  the last disk(s) of this archive.

unzip:  cannot find zipfile directory in one of portable_swiftlint.zip or

portable_swiftlint.zip.zip, and cannot find portable_swiftlint.zip.ZIP,

period.

rake aborted!

Command failed with status (9): [mkdir -p /private/tmp/sandbox/workspace/ve...]

/private/tmp/sandbox/workspace/vendor/bundle/ruby/2.2.0/gems/danger-swiftlint-0.11.0/ext/swiftlint/Rakefile:15:in

`block (2 levels) in <top (required)>'

/tmp/sandbox/workspace/vendor/bundle/ruby/2.2.0/gems/rake-12.2.1/exe/rake:27:in

`<main>'

Tasks: TOP => default => swiftlint:install

(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in

/tmp/sandbox/workspace/vendor/bundle/ruby/2.2.0/gems/danger-swiftlint-0.11.0 for

inspection.

Results logged to

/tmp/sandbox/workspace/vendor/bundle/ruby/2.2.0/extensions/x86_64-darwin-16/2.2.0-static/danger-swiftlint-0.11.0/gem_make.out

An error occurred while installing danger-swiftlint (0.11.0), and Bundler cannot

continue.

Make sure that `gem install danger-swiftlint -v '0.11.0'` succeeds before

bundling.

In Gemfile:

  danger-swiftlint

Skipping Danger - encountered bundler errors
thii commented 6 years ago

@dzenbot The repository was missing a tag for 0.11.0. I just pushed it now. Could you try again?

dzenbot commented 6 years ago

Unfortunately, that didn't help. Any version after 0.8.0 is failing for us, which I can't seem to understand why...

thii commented 6 years ago

Looking at the your CI logs, it looks like the error was caused by being unable to download the portable version of SwiftLint. What is your SWIFTLINT_VERSION value by the way?

dzenbot commented 6 years ago

It is an environment variable that we've been using to fix a Swiftlint version, from https://github.com/ashfurrow/danger-swiftlint#usage

thii commented 6 years ago

I think it was caused by GitHub API limit. You can install SwiftLint via Homebrew or CocoaPods instead.

ashfurrow commented 6 years ago

Okay so this is mysterious – sorry about the problems you've been having.

Bundler is failing when installing danger-swiftlint because the script to install swiftlint is failing. What I don't understand is why Bundler is running the default Rake task when installing the gem.

This line is, I think, overriding the default task:

https://github.com/ashfurrow/danger-swiftlint/blob/af613b1ded2cecd6cdd8d190154ac8d8b7e21bda/ext/swiftlint/Rakefile#L24

We should probably remove that line.

Does anyone know if bundle install runs the default Rake task on install? I've not seen that before, but if that's the case, we should be more careful.

thiagofelix commented 6 years ago

@ashfurrow bundle install should indeed run the default Rake task on /ext folder. The reason is because it is configured on the gemspec

https://github.com/ashfurrow/danger-swiftlint/blob/af613b1ded2cecd6cdd8d190154ac8d8b7e21bda/danger-swiftlint.gemspec#L20

The idea is to always download a specific swiftlint version into the users's computer so we don't need to expect it to be already installed. The purpose is to have a more bullet proof and self contained installation process.

In the past people had either very old/super new versions of swiftlint and the danger plugin wasn't able to integrate with that correctly due to breaking changes between one and another.

ashfurrow commented 6 years ago

Thanks for following up @thiagofelix – I didn't know that!

@dzenbot I'm trying to reproduce the bug but I'm running into problems. The installation is failing when installing SwiftLint here:

https://github.com/ashfurrow/danger-swiftlint/blob/af613b1ded2cecd6cdd8d190154ac8d8b7e21bda/ext/swiftlint/Rakefile#L7-L21

But I'm able to run that locally without issue. Can you try running these two commands?

curl -s -L https://github.com/realm/SwiftLint/releases/download/<SWIFTLINT_VERSION redacted>/portable_swiftlint.zip -o portable_swiftlint.zip
unzip -q portable_swiftlint.zip -d /private/tmp/sandbox/workspace/vendor/bundle/ruby/2.2.0/gems/danger-swiftlint-0.11.0/ext/swiftlint/bin

I think figuring out why this is failing is the next step. Thanks!

Kalvin126 commented 6 years ago

Also seeing this error on our Jenkins CI while getting Danger and this plugin setup 😕 Oddly enough, I do not get this error locally.

ashfurrow commented 6 years ago

@Kalvin126 I am not available this week to work on this issue – if you are able to follow the instructions above for reproducing the error in your CI environment, that would help us fix the problem.

Kalvin126 commented 6 years ago

I am a bit confused why it needs to download swxftlint if we could define a path to a swiftlint binary. Would it be possible to just pass a path to the report.json so it does not have to run the binary?

ashfurrow commented 6 years ago

I think the answer to that question is in @thiagofelix's comment earlier:

The idea is to always download a specific swiftlint version into the users's computer so we don't need to expect it to be already installed. The purpose is to have a more bullet proof and self contained installation process.

Without more info, I can't really diagnose the problem. You're welcome to work on a fork that removes this functionality, or send a PR that can optionally disable it.

dzenbot commented 6 years ago

Since we started using 0.12.1, this has not been an issue for us.

omirho commented 6 years ago

Seems like this is resolved. Closing it.