I wish to place a shell script in my gem's bin dir, along with other Ruby programs that belong to the package. I wish to have this shell script installed in the bin directory as-is (that is, no wrappers). Is that possible with Ruby gems at all? I would be happy with post-install hooks if not otherwise possible. Anybody has any experience with this?
When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/. gem/ruby/1.9. 1 . The commands provided by the gems you installed will end up in ~/.
Publishing to RubyGems.orgVisit the sign up page and supply an email address that you control, a handle (username) and a password. After creating the account, use your email and password when pushing the gem. (RubyGems saves the credentials in ~/. gem/credentials for you so you only need to log in once.)
Step 1: In order to install RubyGems, first we need to install ruby on Linux. Run the following command on the terminal to install ruby. Step 2: Go to the RubyGems download page and click on the zip button, this will download the zip through which you can install RubyGems.
To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs. There are other sources of libraries though.
This issue is described here: https://github.com/rubygems/rubygems/issues/88
If the gem you're developing is intended only for your own use, you can simply install it with
gem install --no-wrapper my_gem
I think you'd best write a ruby script which runs your bash script. Here's an example on how to do that:
bin/test_gem
#!/usr/bin/env ruby
bin_dir = File.expand_path(File.dirname(__FILE__))
shell_script_path = File.join(bin_dir, 'test_gem.sh')
`#{shell_script_path}`
bin/test_gem.sh
#!/bin/sh
echo "Hello World!"
test_gem.gemspec
spec.files = [
# ...
'bin/test_gem', 'bin/test_gem.sh'
]
# ...
spec.executables = ['test_gem']
NOTE: Don't forget to set both files in the bin
folder to executable!
Note that while test_gem.sh
is registered with the files
Rubygems command, it's not registered as executables
: it will just be placed in the installed gem's dir but not wrapped/shimmed.
If you install your gem (and run rbenv rehash if necessary), calling test_gem
will result in the ruby script executing your shell script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With