Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#3398

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.

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

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Josh Nichols
    Josh Nichols
    • Tag changed from 2.3.4, git, install, scriptplugin to 2.3.4, bugmash, git, install, scriptplugin

    January 16th, 2010 @ 04:43 PM

  2. Rizwan Reza
    Rizwan Reza

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

    January 16th, 2010 @ 06:04 PM

  3. Rizwan Reza
    Rizwan Reza

    I used Git version 1.6.5.2.

    January 16th, 2010 @ 07:09 PM

  4. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to resolved

    January 16th, 2010 @ 08:04 PM

  5. Josh Nichols
    Josh Nichols

    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.

    January 17th, 2010 @ 05:23 AM

  6. Pratik
    Pratik
    • State changed from resolved to open

    Reopened as requested by Josh Nichols.

    January 17th, 2010 @ 04:42 PM

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

    February 12th, 2010 @ 12:46 PM

  8. masone
    masone
    • 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.

    July 16th, 2010 @ 03:25 PM

  9. Santiago Pastorino
    Santiago Pastorino
    • 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.

    February 2nd, 2011 @ 04:36 PM

  10. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:36 PM