Gem unpack --target usage

I’m trying to unpack a gem into a particular directory, but cannot get
the --target option to work.

$ gem --version
1.2.0

gem help unpack
Usage: gem unpack GEMNAME [options]

Options:
–target target directory for unpacking

$ gem unpack RedCloth --target /tmp
ERROR: While executing gem … (Gem::CommandLineError)
Too many gem names (RedCloth, /tmp); please specify only one

$ gem unpack RedCloth --target=/tmp
ERROR: While executing gem … (OptionParser::NeedlessArgument)
needless argument: --target=/tmp

How is this supposed to work?

$ gem unpack RedCloth

works fine; trying to give a target not so fine.

Thanks,


James B.

www.happycamperstudios.com - Wicked Cool Coding
www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff

James B. wrote:

I’m trying to unpack a gem into a particular directory, but cannot get
the --target option to work.

gem unpack foo.gem – --target foo # works here.

Erik H. wrote:

James B. wrote:

I’m trying to unpack a gem into a particular directory, but cannot get
the --target option to work.

gem unpack foo.gem – --target foo # works here.

I just tried it. It “works” by unpacking the gem into the current
directory, completely ignoring the --target option.

Not quite what I’m looking for.


James B.

www.happycamperstudios.com - Wicked Cool Coding
www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff

James B. wrote:

Erik H. wrote:

James B. wrote:

I’m trying to unpack a gem into a particular directory, but cannot get
the --target option to work.

gem unpack foo.gem – --target foo # works here.

I just tried it. It “works” by unpacking the gem into the current
directory, completely ignoring the --target option.

What version of rubygems do you have? Mine cleanly unpacked into the
‘foo’ directory. I’m on 1.2.0.

-Erik

James B. wrote:

BTW, why do you use the extra ‘–’ in your example? (Not that it helps
me either way.)

The – indicates that no more arguments are coming; I suspect it’s a bug
(feature?) in rubygems’s argument parser that it wants it this way.

-Erik

Erik H. wrote:

James B. wrote:

Erik H. wrote:

James B. wrote:

I’m trying to unpack a gem into a particular directory, but cannot get
the --target option to work.
gem unpack foo.gem – --target foo # works here.
I just tried it. It “works” by unpacking the gem into the current
directory, completely ignoring the --target option.

What version of rubygems do you have?

I’m using 1.2.0, on Kubuntu, running

ruby 1.8.6 (2008-08-08 patchlevel 286) [i686-linux]

I don’t have a ‘foo.gem’ file to try; I have RedCloth installed as a gem
and want to unpack it to a particular location.

I can unpack to the current directory if I omit any --target option.

So, this works:

james@james06:~$ pwd
/home/james
james@james06:~$ gem unpack RedCloth
Unpacked gem: '/home/james/RedCloth-3.0.4'
james@james06:~$

This fails

james@james06:~$ gem unpack RedCloth --target /tmp/RC
ERROR:  While executing gem ... (Gem::CommandLineError)
    Too many gem names (RedCloth, /tmp/RC); please specify only one
james@james06:~$

Using the extra ‘–’ as in your example acts as if I pass no --target
option:

james@james06:~$ gem unpack RedCloth --  --target /tmp/RC
Unpacked gem: '/home/james/RedCloth-3.0.4'

If I copy the actual gem file to my working directory:

james@james06:~$ gem unpack RedCloth-3.0.4.gem --  --target /tmp/RC
Unpacked gem: '/home/james/RedCloth-3.0.4'


james@james06:~$ gem unpack RedCloth-3.0.4.gem   --target /tmp/RC
ERROR:  While executing gem ... (Gem::CommandLineError)
  Too many gem names (RedCloth-3.0.4.gem, /tmp/RC); please specify
  only one

BTW, why do you use the extra ‘–’ in your example? (Not that it helps
me either way.)


James B.

www.happycamperstudios.com - Wicked Cool Coding
www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff

Le 24 août 2008 à 21:17, James B. a écrit :

I’m trying to unpack a gem into a particular directory, but cannot get
the --target option to work.

Looks like a bug.

Try this :

diff -u rubygems/commands/unpack_command.rb.orig

rubygems/commands/unpack_command.rb
— rubygems/commands/unpack_command.rb.orig Mon Aug 25 12:53:50 2008
+++ rubygems/commands/unpack_command.rb Mon Aug 25 12:53:20 2008
@@ -12,7 +12,7 @@
:version => Gem::Requirement.default,
:target => Dir.pwd

  • add_option(’–target’, ‘target directory for unpacking’) do |value,
    options|
  • add_option(’–target=DIR’, ‘target directory for unpacking’) do
    |value, options|
    options[:target] = value
    end

And…

gem unpack BlueCloth --target=./tmp
Unpacked gem: ‘/home/fred/tmp/BlueCloth-1.0.0’

Fred

F. Senault wrote:

Le 24 août 2008 à 21:17, James B. a écrit :

I’m trying to unpack a gem into a particular directory, but cannot get
the --target option to work.

Looks like a bug.

Try this :

You, sir, are the greatest.

Thank you!


James B.

www.happycamperstudios.com - Wicked Cool Coding
www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff

Le 25 août 2008 à 20:37, James B. a écrit :

F. Senault wrote:

Try this :

You, sir, are the greatest.

Thank you!

Well. If a maintainer of rubygems reads this, I believe it should be
included.

(I tried to submit the patch via rubyforge, but I don’t have an account
there.)

Fred

Erik H. wrote:

James B. wrote:

BTW, why do you use the extra ‘–’ in your example? (Not that it helps
me either way.)

The – indicates that no more arguments are coming; I suspect it’s a bug
(feature?) in rubygems’s argument parser that it wants it this way.

Well, that would explain why, when I run unpack using those dahss it
ignore the subsequent --target option.

I’m thinking now that if you are unpacking foo.gem then, by default, it
will go into foo/ (which is the same as having no --target option, and
which is what you get using the ‘–’ as you have).

If you run

gem unpack foo.gem – --target bar

I think you’d still get a foo/ directory, not bar/


James B.

www.happycamperstudios.com - Wicked Cool Coding
www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff