# Gem help

**URL:** <https://www.ruby-forum.com/t/gem-help/67631>\
**Category:** Ruby\
**Created:** [February 14, 2006, 2:53am UTC](https://www.ruby-forum.com/t/gem-help/67631 "2006-02-14T02:53:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 14, 2006, 2:53am UTC](https://www.ruby-forum.com/t/gem-help/67631/1 "2006-02-14T02:53:00Z")

</div>

i have this

```
 jib:~/eg/ruby/rubyforge/rubyforge-0.1.1 > file bin//rubyforge
 bin//rubyforge: a ruby script text executable

 jib:~/eg/ruby/rubyforge/rubyforge-0.1.1 > cat ./gemspec.rb
 lib, version = 

```

File::basename(File::dirname(File::expand\_path( **FILE** ))).split %r/-/,  
2

```
 require 'rubygems'

 spec = Gem::Specification.new do |s|
   s.name = lib
   s.version = version
   s.platform = Gem::Platform::RUBY
   s.summary = lib

   s.files = Dir["lib/*"] + Dir["bin/*"]

   s.require_path = "lib"
   s.autorequire = lib

   s.has_rdoc = File::exist? "doc"
   s.test_suite_file = "test/#{ lib }.rb" if File::directory? "test"

   s.author = "Ara T. Howard"
   s.email = "removed_email_address@domain.invalid"
   s.homepage = "http://codeforpeople.com/lib/ruby/#{ lib }/"
 end

```

and this gem, apparently, does not install a ‘rubyforge’ script into the  
system  
bin dir. why not?

regards.

-a

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 14, 2006, 3:03am UTC](https://www.ruby-forum.com/t/gem-help/67631/2 "2006-02-14T03:03:30Z")

</div>

removed\_email\_address@domain.invalid wrote:

> and this gem, apparently, does not install a ‘rubyforge’ script into the  
> system  
> bin dir. why not?

Try adding some additional spec items to your gemspec.

The following works for me:

s.bindir = “.” # yours looks to be bin  
s.executables = [“weft-qda.rb”] # or whatever your main script is  
called  
s.default\_executable = “weft-qda.rb”

hth  
alex

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 14, 2006, 3:13am UTC](https://www.ruby-forum.com/t/gem-help/67631/3 "2006-02-14T03:13:15Z")

</div>

unknown wrote:

> i have this
> 
> ```
> jib:~/eg/ruby/rubyforge/rubyforge-0.1.1 > file bin//rubyforge
> bin//rubyforge: a ruby script text executable
> 
> jib:~/eg/ruby/rubyforge/rubyforge-0.1.1 > cat ./gemspec.rb
> lib, version = 
> 
> ```
> 
> File::basename(File::dirname(File::expand\_path( **FILE** ))).split %r/-/,  
> 2
> 
> ```
> require 'rubygems'
> 
> spec = Gem::Specification.new do |s|
> s.name = lib
> s.version = version
> s.platform = Gem::Platform::RUBY
> s.summary = lib
> 
> s.files = Dir["lib/*"] + Dir["bin/*"]
> 
> ```

- 

```
   s.bindir = "bin"

```

- 

```
   s.executables = ["rubyforge"]

```

> ```
> s.require_path = "lib"
> s.autorequire = lib
> 
> s.has_rdoc = File::exist? "doc"
> s.test_suite_file = "test/#{ lib }.rb" if File::directory? "test"
> 
> s.author = "Ara T. Howard"
> s.email = "removed_email_address@domain.invalid"
> s.homepage = "http://codeforpeople.com/lib/ruby/#{ lib }/"
> end
> 
> ```
> 
> and this gem, apparently, does not install a ‘rubyforge’ script into the  
> system  
> bin dir. why not?

Try adding …’

```
     s.bindir = "bin"
     s.executables = ["rubyforge"]

```

Also, I recommend dropping the autorequire as well.

– Jim W.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 14, 2006, 4:19am UTC](https://www.ruby-forum.com/t/gem-help/67631/4 "2006-02-14T04:19:35Z")

</div>

On Tue, 14 Feb 2006, Jim W. wrote:

> > 2
> 
> - 
> 
> ```
> s.bindir = "bin"
> 
> ```
> 
> > ```
> > s.homepage = "http://codeforpeople.com/lib/ruby/#{ lib }/"
> > 
> > ```
> 
> ```
> s.executables = ["rubyforge"]
> 
> ```

thanks.

any reason why

s.executables

would not a default value of

Dir::glob(File::join("#{ bindir }", “\*”)) if File::exist?(bindir)

??

i actually did try that btw. the reason it didn’t work is because the  
bindir  
installed to is not in my path. i have something like this setup

/usr/local/bin/ruby -\> /usr/local/ruby-1.8.4/bin/ruby

/usr/local/ruby-1.8.4/\*  
/usr/local/ruby-1.8.3/\*  
/usr/local/ruby-1.8.2/\*  
/usr/local/ruby-1.8.1/\*

etc.

so here a

gem install rubyforge-0.0.0.gem

installs into

/usr/local/bin/ruby-1.8.4/bin/rubyforge

which is not in my path.

a while back i posted this tiny patch the the top-level gem script

```
#
# munge rbconfig from any command line or environment kv pair
#
 kvs = []
 re = %r/^ \s* ([^=\s]+) \s* = \s* ([^\s]+) \s* $/x
 args.delete_if{|arg| (m = re.match(arg)) and (kvs << 

```

m.to\_a.last(2))}  
ENV::each{|k,v| (k =~ %r/^GEM\_/) and (kvs \<\< [k.delete(‘GEM\_’),  
v])}  
unless kvs.empty?  
require ‘rbconfig’  
kvs.each{|k,v| Config::CONFIG[k] = v}  
end

which allows setting of **any** rbconfig value on the command line.  
this  
allows one to do this:

gem install rubyforge-0.0.0.gem bindir=/usr/local/bin/

and other fine grained controls of any gem install. any objection to  
adding  
such a patch to gems? as it stands now i cannot use the gem command to  
manage  
anything but libs on my systems - commands simply disappear into non  
PATH  
directories.

regards.

-a

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 14, 2006, 4:23am UTC](https://www.ruby-forum.com/t/gem-help/67631/5 "2006-02-14T04:23:38Z")

</div>

On Tue, 14 Feb 2006, Jim W. wrote:

i should have included to complete patched ‘gem’ script:

#!/usr/bin/env ruby

```
 require 'rubygems'
 Gem.manage_gems

 required_version = Gem::Version::Requirement.new(">= 1.8.0")
 unless 

```

required\_version.satisfied\_by?(Gem::Version.new(RUBY\_VERSION))  
puts “Expected Ruby Version #{required\_version}, was  
#{RUBY\_VERSION}”  
exit(1)  
end

# We need to preserve the original ARGV to use for passing gem

options

# to source gems. If there is a – in the line, strip all options

after

# it…its for the source building process.

```
 args = !ARGV.include?("--") ? ARGV.clone : 

```

ARGV[0…ARGV.index("–")]

# 

# munge rbconfig from any command line or environment kv pair

# 

```
 kvs = []
 re = %r/^ \s* ([^=\s]+) \s* = \s* ([^\s]+) \s* $/x
 args.delete_if{|arg| (m = re.match(arg)) and (kvs << 

```

m.to\_a.last(2))}  
ENV::each{|k,v| (k =~ %r/^GEM\_/) and (kvs \<\< [k.delete(‘GEM\_’),  
v])}  
unless kvs.empty?  
require ‘rbconfig’  
kvs.each{|k,v| Config::CONFIG[k] = v}  
end

```
 Gem::GemRunner.new.run(args)

```

not that env settings affect the install as well. so one can do

GEM\_BINDIR=/usr/local/bin gem install somelib.gem

regards.

-a
