I’m usually reluctant to go change “big things”, almost always preferring to work around any issues I encounter. On the rare occasion though, I find I really must make changes or I’d forget what I did and struggle with it again later.
The script/plugin install command in Rails is a wonderful thing. It fetches code from repositories (like subversion or github) and installs it into your Rails application. Plugins generally extend Rails’ capabilities, much in the way that Ruby is extended through Rubygems. However, the plugin installer assumes a repository, or at least the web. If there is a local copy of the plugin in your environment that you’d like to use as the source, you’re out of luck. You have to do the install by hand, and remember to set up some environment specification. There’s just no provision for local installs.
Necessity being the mother of invention, when I found myself needing to install a plugin from local sources, I tried to find a workaround. When I could find nothing satisfying, I did some editing. A very slight amount of editing.
That is, if the specified plugin being installed starts with a slash, assume it’s an absolute path to the directory that contains the plugin and fetch it by copying. Then the install can go along it’s merry way.
Now I can just fire off a
and it will install the
foo plugin in the specified directory into my Rails project, just as if it were out on the net.
This certainly may not be perfect, and if I were polishing it I’d add a check for a
file: protocol and include relative paths, but this was just enough for my needs.