Erreur lors de l'exécution de l'exécutable à partir de la gemme car une autre gemme ne fait pas partie du bundle

StackOverflow https://stackoverflow.com//questions/25021077

Question

Je crée un joyau (voir https://github.com/hamchapman/rewinder) qui a ruby-git (https://github.com/schacon/ruby-git) comme dépendance.

Une partie de mon joyau a un exécutable https://github.com/hamchapman/rewinder/blob/master/bin/rewinder

ce qui nécessite simplement le fichier lib principal https://github.com/hamchapman/rewinder/blob/master/lib/rewinder.rb

puis exécute la méthode là-bas (tout est compliqué pour le moment - ignorez cela pour l'instant).

Lorsque j'installe la gemme localement et que je l'utilise dans un autre dépôt, j'obtiens l'erreur suivante :

/Users/Hami/.rvm/gems/ruby-2.1.2/gems/git-1.2.7/lib/git/lib.rb:764:in `command': git checkout '6eef72baf24bed761f753267cce16402e4a947f8'  2>&1:Note: checking out '6eef72baf24bed761f753267cce16402e4a947f8'. (Git::GitExecuteError)

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 6eef72b... Trying another bg-color change for homeboy
/Users/Hami/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/rubygems_integration.rb:252:in `block in replace_gem': hookup is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
    from /Users/Hami/.rvm/gems/ruby-2.1.2/bin/hookup:22:in `<main>'
    from /Users/Hami/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
    from /Users/Hami/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
    from /Users/Hami/.rvm/gems/ruby-2.1.2/gems/git-1.2.7/lib/git/lib.rb:528:in `checkout'
    from /Users/Hami/.rvm/gems/ruby-2.1.2/gems/git-1.2.7/lib/git/base.rb:325:in `checkout'
    from /Users/Hami/.rvm/gems/ruby-2.1.2/gems/rewinder-0.0.1/lib/rewinder.rb:11:in `block in heloo'
    from /Users/Hami/.rvm/gems/ruby-2.1.2/gems/rewinder-0.0.1/lib/rewinder.rb:10:in `each'
    from /Users/Hami/.rvm/gems/ruby-2.1.2/gems/rewinder-0.0.1/lib/rewinder.rb:10:in `each_with_index'
    from /Users/Hami/.rvm/gems/ruby-2.1.2/gems/rewinder-0.0.1/lib/rewinder.rb:10:in `heloo'
    from /Users/Hami/.rvm/gems/ruby-2.1.2/gems/rewinder-0.0.1/bin/rewinder:4:in `<top (required)>'
    from /Users/Hami/.rvm/gems/ruby-2.1.2/bin/rewinder:23:in `load'
    from /Users/Hami/.rvm/gems/ruby-2.1.2/bin/rewinder:23:in `<main>'
    from /Users/Hami/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
    from /Users/Hami/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'

Je ne comprends pas vraiment l'erreur car ni ma gemme, ni la gemme ruby-git ne l'ont hookup comme une dépendance.Si je charge le fichier /Users/Hami/.rvm/gems/ruby-2.1.2/bin/hookup

puis commentez les deux lignes du bas comme ceci :

#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'hookup' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first
  str = ARGV.first
  str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
  if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
    version = $1
    ARGV.shift
  end
end

#gem 'hookup', version
#load Gem.bin_path('hookup', 'hookup', version)

alors l'erreur ne se produit pas.

D'après ce que j'ai lu, il semble que cela pourrait avoir quelque chose à voir avec la façon dont oh-my-zsh encapsule certaines commandes - peut-être en enveloppe-t-il une de git ?

Aucune suggestion?

Était-ce utile?

La solution

Du documentation de connexion:

Chaque fois que votre HEAD actuel change, le branchement vérifie si votre Gemfile, Gemfile.lock, ou la spécification de la gemme a changé.Si tel est le cas, il exécute la vérification du bundle, et si cela indique que des dépendances ne sont pas satisfaites, il exécute l'installation du bundle.

De là, je déduis que la gemme écoute git checkout événements.Puisque vous faites cela dans votre code, les hooks de connexion prennent vie et deviennent confus (que cela fasse ou non partie de votre application Ruby).

Essayez de désinstaller la gemme et réessayez.

Si cela résout votre problème, vous pouvez envisager d'ouvrir un problème à l'auteur de la gemme pour résoudre ce problème.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top