I'm using the standard bundler/capistrano recipe that installs all necessary gems on the server after deploy:update_code
我正在使用标准的bundler / capistrano配方,它在部署后在服务器上安装所有必需的宝石:update_code
Works like a charm and has simplified my life significantly.
像魅力一样工作,显着简化了我的生活。
I'm using Rails 2.3.10 and 'patched' the boot.rb and created the preinitializer as was necessary.
我正在使用Rails 2.3.10并“修补”boot.rb并根据需要创建了preinitializer。
My question is, how does Rails know that my gems reside in the shared/bundle directory, and how does it know to use these? Is this directory somehow automatically added to the load path? How do these gems take precedent over system gems?
我的问题是,Rails如何知道我的gem位于shared / bundle目录中,以及它如何知道使用它们?此目录是否以某种方式自动添加到加载路径?这些宝石如何先于系统宝石?
2 个解决方案
#1
11
jdl, thanks for the heads up on where to look. Here's my understanding of what happens.
jdl,感谢您前往哪里寻找。这是我对发生的事情的理解。
Bundler automatically installs the gems into shared/bundle, as specified using bundle_dir
from the Gemfile, it defaults to this:
Bundler自动将gem安装到shared / bundle中,如使用Gemfile中的bundle_dir指定的那样,默认为:
# (line 39 bundler/deployment.rb)
set :bundle_dir, File.join(fetch(:shared_path), 'bundle')
:shared_path
comes from capistrano
:shared_path来自capistrano
So that's step one of installing the gems. Now, as far as I understand, when you specify a directory to install gems into, Bundler always modifies the .bundle/config
in the root dir (ie where the Gemfile
is located). This is what mine looks like after doing that bundle install to the shared dir:
这就是安装宝石的第一步。现在,据我所知,当你指定一个目录来安装gems时,Bundler总是修改根目录中的.bundle / config(即Gemfile所在的位置)。这是我在对共享目录进行捆绑安装后的样子:
---
BUNDLE_DISABLE_SHARED_GEMS: "1"
BUNDLE_WITHOUT: development:test
BUNDLE_FROZEN: "1"
BUNDLE_PATH: /mnt/apps/my_app/shared/bundle
Then, (as pointed out by jdl) the GEM_HOME gets set based off this .bundle/config.
然后,(正如jdl所指出的)GEM_HOME基于此.bundle / config进行设置。
The method configure_gem_home_and_path
in bundler.rb
sets ENV['GEM_HOME']
and it's based off of some settings, that, through a convoluted process end up getting the BUNDLE_PATH
from your .bundle/config.
bundler.rb中的configure_gem_home_and_path方法设置ENV ['GEM_HOME'],它基于一些设置,通过一个复杂的进程最终从.bundle / config获取BUNDLE_PATH。
whew...
#2
0
The GEM_HOME
environment variable is what you're looking for.
您正在寻找GEM_HOME环境变量。
文件在这里。
#1
11
jdl, thanks for the heads up on where to look. Here's my understanding of what happens.
jdl,感谢您前往哪里寻找。这是我对发生的事情的理解。
Bundler automatically installs the gems into shared/bundle, as specified using bundle_dir
from the Gemfile, it defaults to this:
Bundler自动将gem安装到shared / bundle中,如使用Gemfile中的bundle_dir指定的那样,默认为:
# (line 39 bundler/deployment.rb)
set :bundle_dir, File.join(fetch(:shared_path), 'bundle')
:shared_path
comes from capistrano
:shared_path来自capistrano
So that's step one of installing the gems. Now, as far as I understand, when you specify a directory to install gems into, Bundler always modifies the .bundle/config
in the root dir (ie where the Gemfile
is located). This is what mine looks like after doing that bundle install to the shared dir:
这就是安装宝石的第一步。现在,据我所知,当你指定一个目录来安装gems时,Bundler总是修改根目录中的.bundle / config(即Gemfile所在的位置)。这是我在对共享目录进行捆绑安装后的样子:
---
BUNDLE_DISABLE_SHARED_GEMS: "1"
BUNDLE_WITHOUT: development:test
BUNDLE_FROZEN: "1"
BUNDLE_PATH: /mnt/apps/my_app/shared/bundle
Then, (as pointed out by jdl) the GEM_HOME gets set based off this .bundle/config.
然后,(正如jdl所指出的)GEM_HOME基于此.bundle / config进行设置。
The method configure_gem_home_and_path
in bundler.rb
sets ENV['GEM_HOME']
and it's based off of some settings, that, through a convoluted process end up getting the BUNDLE_PATH
from your .bundle/config.
bundler.rb中的configure_gem_home_and_path方法设置ENV ['GEM_HOME'],它基于一些设置,通过一个复杂的进程最终从.bundle / config获取BUNDLE_PATH。
whew...
#2
0
The GEM_HOME
environment variable is what you're looking for.
您正在寻找GEM_HOME环境变量。
文件在这里。