Project

General

Profile

Bug #9004

gem which command should exit with status of '1' if 1 or more gem arguments are not found

Added by evilensky (Eugene Vilensky) almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.4.0]
[ruby-core:57737]

Description

=begin
Many unix utilities exit with a code of 1 if any parts of the command fail, in particular ((%rpm%)). I believe its desirable for ((%gem which%)) to behave similar to ((%rpm -q%)) for this use case.

# rpm -q man
man-1.6f-32.el6.x86_64
# echo $?
0

# rpm -q man cheese
man-1.6f-32.el6.x86_64
package cheese is not installed
# echo $?
1

$ gem which capistrano
/opt/boxen/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/capistrano-2.15.5/lib/capistrano.rb
evilensky@Vilensky~/src/puppet/lib/puppet (add-yum-uninstall-to-yum-provider)$ echo $?
0

$ gem which capistrano rails
/opt/boxen/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/capistrano-2.15.5/lib/capistrano.rb
ERROR: Can't find ruby library file or shared library rails
$ echo $?
0
=end

gem_which.patch (898 Bytes) gem_which.patch phluid61 (Matthew Kerwin), 11/06/2013 09:30 AM

Associated revisions

Revision 43714
Added by drbrain (Eric Hodel) almost 4 years ago

  • lib/rubygems: Update to RubyGems master 6a3d9f9. Changes include:

Compatibly renamed Gem::DependencyResolver to Gem::Resolver.

Added support for git gems in gem.deps.rb and Gemfile.

Fixed resolver bugs.

  • test/rubygems: ditto.

  • lib/rubygems/LICENSE.txt: Updated to license from RubyGems trunk.
    [ruby-trunk - Bug #9086]

  • lib/rubygems/commands/which_command.rb: RubyGems now indicates
    failure when any file is missing. [ruby-trunk - Bug #9004]

  • lib/rubygems/ext/builder: Extensions are now installed into the
    extension install directory and the first directory in the require
    path from the gem. This allows backwards compatibility with msgpack
    and other gems that calculate full require paths.
    [ruby-trunk - Bug #9106]

Revision 43714
Added by drbrain (Eric Hodel) almost 4 years ago

  • lib/rubygems: Update to RubyGems master 6a3d9f9. Changes include:

Compatibly renamed Gem::DependencyResolver to Gem::Resolver.

Added support for git gems in gem.deps.rb and Gemfile.

Fixed resolver bugs.

  • test/rubygems: ditto.

  • lib/rubygems/LICENSE.txt: Updated to license from RubyGems trunk.
    [ruby-trunk - Bug #9086]

  • lib/rubygems/commands/which_command.rb: RubyGems now indicates
    failure when any file is missing. [ruby-trunk - Bug #9004]

  • lib/rubygems/ext/builder: Extensions are now installed into the
    extension install directory and the first directory in the require
    path from the gem. This allows backwards compatibility with msgpack
    and other gems that calculate full require paths.
    [ruby-trunk - Bug #9106]

Revision 43714
Added by drbrain (Eric Hodel) almost 4 years ago

  • lib/rubygems: Update to RubyGems master 6a3d9f9. Changes include:

Compatibly renamed Gem::DependencyResolver to Gem::Resolver.

Added support for git gems in gem.deps.rb and Gemfile.

Fixed resolver bugs.

  • test/rubygems: ditto.

  • lib/rubygems/LICENSE.txt: Updated to license from RubyGems trunk.
    [ruby-trunk - Bug #9086]

  • lib/rubygems/commands/which_command.rb: RubyGems now indicates
    failure when any file is missing. [ruby-trunk - Bug #9004]

  • lib/rubygems/ext/builder: Extensions are now installed into the
    extension install directory and the first directory in the require
    path from the gem. This allows backwards compatibility with msgpack
    and other gems that calculate full require paths.
    [ruby-trunk - Bug #9106]

Revision 43714
Added by drbrain (Eric Hodel) almost 4 years ago

  • lib/rubygems: Update to RubyGems master 6a3d9f9. Changes include:

Compatibly renamed Gem::DependencyResolver to Gem::Resolver.

Added support for git gems in gem.deps.rb and Gemfile.

Fixed resolver bugs.

  • test/rubygems: ditto.

  • lib/rubygems/LICENSE.txt: Updated to license from RubyGems trunk.
    [ruby-trunk - Bug #9086]

  • lib/rubygems/commands/which_command.rb: RubyGems now indicates
    failure when any file is missing. [ruby-trunk - Bug #9004]

  • lib/rubygems/ext/builder: Extensions are now installed into the
    extension install directory and the first directory in the require
    path from the gem. This allows backwards compatibility with msgpack
    and other gems that calculate full require paths.
    [ruby-trunk - Bug #9106]

History

#1 [ruby-core:57739] Updated by evilensky (Eugene Vilensky) almost 4 years ago

Apologies for breaking the formatting of Description.

rpm case

rpm -q man

man-1.6f-32.el6.x86_64

echo $?

0

rpm -q man cheese

man-1.6f-32.el6.x86_64
package cheese is not installed

echo $?

1
gem which case

$ gem which capistrano
/opt/boxen/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/capistrano-2.15.5/lib/capistrano.rb
evilensky@Vilensky~/src/puppet/lib/puppet (add-yum-uninstall-to-yum-provider)$ echo $?
0
$ gem which capistrano rails
/opt/boxen/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/capistrano-2.15.5/lib/capistrano.rb
ERROR: Can't find ruby library file or shared library rails
$ echo $?
0

#2 [ruby-core:57760] Updated by nobu (Nobuyoshi Nakada) almost 4 years ago

  • Description updated (diff)

#3 [ruby-core:58192] Updated by phluid61 (Matthew Kerwin) almost 4 years ago

=begin
Patch causes gem which to return 1 if there are no args, or if any of the args is not found.

$ gem which ; echo $?
1
$ gem which rake ; echo $?
/usr/local/lib/ruby/2.1.0/rake.rb
0
$ gem which rake rails ; echo $?
/usr/local/lib/ruby/2.1.0/rake.rb
ERROR: Can't find ruby library file or shared library rails
1

=end

#4 Updated by drbrain (Eric Hodel) almost 4 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r43714.
Eugene, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/rubygems: Update to RubyGems master 6a3d9f9. Changes include:

Compatibly renamed Gem::DependencyResolver to Gem::Resolver.

Added support for git gems in gem.deps.rb and Gemfile.

Fixed resolver bugs.

  • test/rubygems: ditto.

  • lib/rubygems/LICENSE.txt: Updated to license from RubyGems trunk.
    [ruby-trunk - Bug #9086]

  • lib/rubygems/commands/which_command.rb: RubyGems now indicates
    failure when any file is missing. [ruby-trunk - Bug #9004]

  • lib/rubygems/ext/builder: Extensions are now installed into the
    extension install directory and the first directory in the require
    path from the gem. This allows backwards compatibility with msgpack
    and other gems that calculate full require paths.
    [ruby-trunk - Bug #9106]

Also available in: Atom PDF