问题描述
我在这里遇到一些麻烦。我正在使用Rails 2.3项目(通过ssh在生产服务器上工作 - 不要问为什么)。这是。当delayed_jobs尝试启动时,输出说我需要安装捆绑软件gem。问题是gemdir是/var/lib/gems/1.8/,我没有该目录的写入权限。但是我可以在〜/ projects / shared / gems / ruby / 1.8 / gems下面找到一个目录。如何定义gem的安装路径?
您可以将以下内容添加到 config.ru 文件中:
ENV ['GEM_HOME'] =#{ENV ['HOME']} / projects / shared / gems / ruby / 1.8 / gems
ENV ['GEM_PATH'] =#{ENV ['GEM_HOME']}:/ var / lib /ruby/gems/1.8
require'rubygems'
Gem.clear_paths
这将告诉你的机架应用程序在哪里寻找宝石。
同时配置您的服务器 .bashrc :
export GEM_HOME =$ HOME / projects / shared / gems / ruby / 1.8 / gems
export GEM_PATH =$ GEM_HOME:/ var / lib /ruby/gems/1.8
I have some trouble here. I am working with a Rails 2.3 project (working on the production server through ssh - don't ask why). Here is the Gemfile. When delayed_jobs is trying to start, the output says I need to install the bundler gem. The problem is that the gemdir is /var/lib/gems/1.8/ and I don't have the write priviliges for that directory. However there is a directory under ~/projects/shared/gems/ruby/1.8/gems where I can write.
How can I define the installation path for a gem?
You can add the following to your config.ru file:
ENV['GEM_HOME']="#{ENV['HOME']}/projects/shared/gems/ruby/1.8/gems"
ENV['GEM_PATH']="#{ENV['GEM_HOME']}:/var/lib/ruby/gems/1.8"
require 'rubygems'
Gem.clear_paths
This will tell your rack app where to look for gems.
Also configure your server .bashrc:
export GEM_HOME="$HOME/projects/shared/gems/ruby/1.8/gems"
export GEM_PATH="$GEM_HOME:/var/lib/ruby/gems/1.8"
这篇关于指定gem安装目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!