Execution of ruby script fails with "abort trap: 6" error message

Description of the issue

Execution of ruby script fails with “abort trap: 6” error message.


Where did the issue happen?
Bitrise iOS Xcode 8.2.x

Which build Step causes the issue and which version of the step?
Ruby script execution - any version

The script I’m trying to execute is the following (relevant bits):

require 'xcodeproj'

def change_bundle_id(project_name, target_name, project_configuration, project_filepath, new_bundle_ID)
  project_directory=File.dirname project_filepath

  puts "Parsing project at '#{project_filepath}'"
  project = Xcodeproj::Project.open(project_filepath)
  target = project.targets.find { |t| t.name == target_name }
  exit -12 if target.nil?

  configuration = target.build_configurations.find { |c| c.name == project_configuration }
  exit -12 if configuration.nil?

  puts "Setting Xcode Project's PRODUCT_BUNDLE_IDENTIFIER to '#{new_bundle_ID}'"

  configuration.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = new_bundle_ID
  puts "done!"
  puts "done!!"


The issue happens all the time.

Other stacks

The issue doesn’t appear when run locally with CLI

Build log

Relevant bits:

-> Writing Gemfile
$ bundle install
Fetching gem metadata from https://rubygems.org/...............
Fetching version metadata from https://rubygems.org/.
Resolving dependencies...
Installing concurrent-ruby 1.0.5
Installing i18n 0.8.1
Installing minitest 5.10.1
Installing thread_safe 0.3.6
Using claide 1.0.1
Using colored 1.2
Installing plist 3.2.0
Using bundler 1.13.6
Using tzinfo 1.2.2
Installing activesupport 5.0.2
Installing xcodeproj 1.3.3
Bundle complete! 2 Gemfile dependencies, 11 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Parsing project at 'Harmony/Harmony.xcodeproj'
Setting Xcode Project's PRODUCT_BUNDLE_IDENTIFIER to 'com.harmonyplatform.harmony'
/var/folders/90/5stft2v13fb_m_gv3c8x9nwc0000gn/T/bitrise005010995/step_src/step.sh: line 52:  1107 Abort trap: 6           BUNDLE_GEMFILE="${CONFIG_gemfile_path}" bundle exec ruby "${CONFIG_ruby_content_file}"
--- finished ---
|                                                                              |
| x | Bundle ID (exit code: 134)                                    | 17 sec   |
| Issue tracker: https://github.com/bitrise-io/steps-ruby-script/issues        |
| Source: https://github.com/bitrise-io/steps-ruby-script                      |

Hi @FWFabio,

Seems like a Ruby (gem?) issue - searching for “abort trap: 6”:

Seems like a memory allocation issue in the code somewhere.

That’s a generic error that happens when ruby crashes.
It works flawlessly on my machine via bitrise CLI, with the same ruby version so I have no idea how to fix it.

Can you try to replace the Ruby Script step, and instead store your ruby script into your repo and just run with with a normal/Bash script (the Script step), like:

set -ex

ruby ./path/to/script.rb


Ah! I fixed by trying a different version of the xcodeproj gem!
Still unsure where the problem was, but a different version seems to work perfectly.

1 Like

That was what I suspected too, that one of your dependency GEM versions had a memory allocation issue causing “abort trap: 6”, but I couldn’t pinpoint it.

Thanks @FWFabio for sharing the solution! Just a question: what was the faulty version and which version fixed it? Just for future ref. in case someone else would have this issue.

1.3.3 was failing. 1.4.2 works perfectly.

1 Like

Thanks for the info @FWFabio, I’m sure it’ll help others in the future! :wink: