Install gem and use it in the next script

I have a bash script that installs a gem (plist gem) and then I have another ruby script after that which tries to require ‘plist’ but fails. Should this work?

==> Start

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- plist (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:inrequire’
from /var/folders/lb/8n5bn9k975qgw662jpqdy7mm0000gn/T/bitrise913294069/step_src/._script_cont:3:in `’

==> Script finished with exit code: 1

1 Like

How do you install the gem? With gem install or with sudo gem install?

Also, I’d advise you to use a Gemfile if possible, so that you can bundle exec .. your ruby script, which ensures that all the gems from the Gemfile are available; or alternatively use the Ruby Script runner with optional Gemfile support step instead of the Script step, where you can specify both the (ruby) script content and a Gemfile content, and the step will make it sure that the gems declared in the Gemfile input are available (essentially it bundle install && bundle exec .. it for you).

1 Like

Thanks that did it :slight_smile:

1 Like

Which one? bundle install && bundle exec or the Ruby Script step? (just to make this clear for others who’ll read this conversation :wink: )

Ruby Script - I am sure the other approach works as well tho.

1 Like

Thank you @convodev! :slight_smile: