In many ways, RubyGems will take care of this for you. You will need to include the executable in the files list and put it in executables in your gemspec. Usually for your executable in bin in your directory, for example:
$ ls bin/ myapp.gemspec lib/ Rakefile $ ls bin bin/myapp
Your gemspec would now look like this:
Gem::Specification.new do |s| s.name = 'myapp'
At this point, when users install your application through RubyGems, myapp will be on its way, and lib will be in your application download path, so your executable can simply start with:
#!/usr/bin/env ruby require 'myapp'
The only problem is that during development, you cannot just make bin/myapp and run the application. Some developers manipulate by loading via $: or $LOAD_PATH , but this is considered a bad form.
If you use bundler, the easiest way to run the application locally is with bundle exec , for example. bundle exec bin/myapp . You can use the RUBYLIB environment RUBYLIB , for example, one at a time. RUBYLIB=lib bin/myapp , which will put lib in the boot path.
source share