Bill L
Bill L

Reputation: 2826

How to distribute a Ruby script with required gems

I have a Ruby script that is running into problems because the end-users don't have all the required gems. I've been looking into the issue and it seems packaging it as a gem is the best way to make sure it will work for anyone.

  1. Is this the best way to distribute a Ruby script and not have to worry about the end-user not having a gem at runtime?
  2. If I do it this way, how would the end-user run the script? Right now they are executing it using ruby script_name and I am writing a bash script to automatically run it for them.
  3. Could I still have a bash script that could run the script if it's installed as a gem? Having a double-clickable file to run the script is a godsend for people who need to use it who aren't as technically inclined.

Upvotes: 1

Views: 393

Answers (1)

erahm
erahm

Reputation: 344

I'm operating off of the assumption that your required gems are in a Gemfile. If you're having them run a bash script to run your Ruby script, have you considered adding bundle install to the bash script prior to having it run your Ruby script? This will install all the required gems before running the script.

Another option would be to setup a Docker container that already has all the gems installed and just automatically runs the Ruby script. This would get you around issues with your users having the wrong version of Ruby, but has the added cost of having them install Docker.

Upvotes: 2

Related Questions