This project is archived and is in readonly mode.

#3398 ✓stale
Josh Nichols

script/plugin install fails doesn't populate new directory in vendor/plugins

Reported by Josh Nichols | October 21st, 2009 @ 08:45 AM

Using rails 2.3.4, ruby 1.8.7 (2009-06-12 patchlevel 174), and git 1.6.5.rc2, behold this:

$ script/plugin install git://github.com/thoughtbot/paperclip.git
Initialized empty Git repository in /Users/technicalpickles/code/scratch/upupload/vendor/plugins/paperclip/.git/
$ ls vendor/plugins/paperclip
$

Seems the problem is around railties/lib/commands/plugin.rb ... when system('git pull --depth 1...') is called, this exits with 1 (confirmed in the shell by doing it by hand).

$ mkdir -p vendor/plugins/paperclip
$ cd vendor/plugins/paperclip
$ git init
Initialized empty Git repository in /Users/technicalpickles/code/scratch/upupload/vendor/plugins/paperclip/.git/
$ git pull --depth 1 git://github.com/thoughtbot/paperclip.git -q
$ echo $?
1

I'm not sure why this particular approach of init & pull is used rather than just cloning. I was able to get it working by replacing Commands::Plugin#install_using_git with this:

    def install_using_git(options = {})
      root = rails_env.root
      install_path = mkdir_p "#{root}/vendor/plugins/#{name}"
      base_cmd = "git clone #{uri}"
      base_cmd += " -q" if options[:quiet] and not $verbose
      base_cmd += " #{options[:revision]}" if options[:revision]
      base_cmd += " #{install_path}"
      if system(base_cmd)
        puts "removing: .git .gitignore" if $verbose
        rm_rf %W(#{install_path}/.git #{install_path}/.gitignore)
      else
        rm_rf install_path
      end
    end

... and it seems to work well enough. On aside, the else should probably display an error message or otherwise notifiy the user what happened.

Comments and changes to this ticket

  • Josh Nichols

    Josh Nichols January 16th, 2010 @ 04:43 PM

    • Tag changed from 2.3.4, git, install, scriptplugin to 2.3.4, bugmash, git, install, scriptplugin
  • Rizwan Reza

    Rizwan Reza January 16th, 2010 @ 06:04 PM

    I can't seem to reproduce this error. The plugin is cloned into the plugins directory as it should.

  • Rizwan Reza

    Rizwan Reza January 16th, 2010 @ 07:09 PM

    I used Git version 1.6.5.2.

  • Jeremy Kemper

    Jeremy Kemper January 16th, 2010 @ 08:04 PM

    • State changed from “new” to “resolved”
  • Josh Nichols

    Josh Nichols January 17th, 2010 @ 05:23 AM

    I've tested with a non-RC version, 1.6.6, and still see the same behavior.

    Looking at the code suggests that something about the git command is not exiting cleanly (ie non-zero exit code), and falling into the else clause that silently removes the failed-to-clone plugin.

  • Pratik

    Pratik January 17th, 2010 @ 04:42 PM

    • State changed from “resolved” to “open”

    Reopened as requested by Josh Nichols.

  • Rizwan Reza

    Rizwan Reza February 12th, 2010 @ 12:46 PM

    • Tag changed from 2.3.4, bugmash, git, install, scriptplugin to 2.3.4, git, install, scriptplugin
  • masone

    masone July 16th, 2010 @ 03:25 PM

    • Importance changed from “” to “”

    Can't reproduce this either. The return code from git is 0.

    OSX, git version 1.6.5.1, ruby 1.8.7 (2010-06-23 patchlevel 299)

    Josh: It does a pull --depth 1 because this only fetches the newest revision. A clone would get the whole history too.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:36 PM

    • Tag changed from 2.3.4, git, install, scriptplugin to 234, git, install, scriptplugin

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:36 PM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages