If I download a .gem file to a folder in my computer, can I install it later using gem install
?
问题:
回答1:
Yup, when you do gem install
, it will search the current directory first, so if your .gem file is there, it will pick it up. I found it on the gem reference, which you may find handy as well:
gem install will install the named gem. It will attempt a local installation (i.e. a .gem file in the current directory), and if that fails, it will attempt to download and install the most recent version of the gem you want.
回答2:
Also, you can use gem install --local path_to_gem/filename.gem
This will skip the usual gem repository scan that happens when you leave off --local
.
You can find other magic with gem install --help
.
回答3:
you can also use the full filename to your gem file:
gem install /full/path/to/your.gem
this works as well -- it's probably the easiest way
回答4:
If you create your gems with bundler:
# do this in the proper directory
bundle gem foobar
You can install them with rake after they are written:
# cd into your gem directory
rake install
Chances are, that your downloaded gem will know rake install
, too.
回答5:
if you download the project file from github or other scm host site, use gem build to build the project first, so you can get a whatever.gem file in current directory. Then gem install it!
回答6:
If you want to work on a locally modified fork of a gem, the best way to do so is
gem 'pry', path: './pry'
in a Gemfile.
... where ./pry
would be the clone of your repository. Simply run bundle install
once, and any changes in the gem sources you make are immediately reflected. With gem install pry/pry.gem
, the sources are still moved into GEM_PATH
and you'll always have to run both bundle gem pry
and gem update
to test.
回答7:
Go to the path in where the gem is and call gem install -l gemname.gem