Is there a way to specify in the Gemfile where each gem should be installed? The expected result would be later if I type in my Rails application directory:
bundle install
then according to the Gemfile, some gems will by default be installed into system-default gempath or the path specified in previous --path option, while some other gems will be downloaded and installed into the path specified using Gemfile.
How may I do this by Gemfile? Or maybe using .bundle/config? Any ideas?
Using --path option of bundle is not a solution because it will enforce all gems installed into that same directory. For example, if I have dependencies on 4 gems: A, B, C, and D. I would like to run bundle command then, automatically, A and C are installed into the default dir while B and D are installed into a customized one.
Also using the following line in a Gemfile is not a solution:
gem 'rspec', :path => 'some/path'
because this requires users manually download that Gem and put it into the specified path beforehand, but I would like the Gem automatically downloaded and installed into that path. Is it possible? How?
Thanks!
As far as I know the bundler gem really follows your advise and installs everything to the in --path=/your/path
specified path. So normally there should be no problem as long as you use
$ bundle install --path=/your/path
Anyway if you want to prevent bundler to install something globally even if you didn't set the --path
flag, you can set a global gem
prefix. With the --user
flag every gem will be installed to your home directory. Just add gem: --user-install
to your .gemrc
$ echo "gem: --user-install" > ~/.gemrc
Be aware that this rule is also used if you install a gem manually with
$ gem install my_awesome_gem
You can specify your gem installation directory in file 文件中指定您的gem安装目录
Refer this answer: Specify gem installation directory
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.