[英]How to install gem in Ruby / RoR script?
I have a problem with this 我有这个问题
rails console
Loading development environment (Rails 3.2.13)
irb(main):001:0> system "bundle install"
←[31mssh://git@sykav-sr-pr-004.domain.local:7999/kpr/kpr_exchange.git (at master) is not checked out. Please run `bundle install`←[0m
=> false
UPD UPD
It's work for me: 这对我有用:
Bundler.with_original_env { system('bundle install') }
result code for bundle install after add gem in gemfile: 在gemfile中添加gem后,捆绑安装的结果代码:
def update_bundler
crashed = false
begin
puts "START 'bundle install'"
result = nil
Bundler.with_original_env { result = system('bundle install') }
raise if !result
puts "DONE"
rescue
puts "WE HAVE PROBLEM IN bundler"
crashed = true
FileUtils.cp("Gemfile_backup", "Gemfile")
end
crashed
end
Console 安慰
The problem you have is you're using the Rails console
- you don't want to do that, you want to use your standard system
CMD
: 您遇到的问题是您正在使用
Rails console
-您不想这样做,而是想使用标准system
CMD
:
$ rails c
$ ... your stuff
$ exit
$ bundle install
Rails is a gem too - meaning if you load the Rails console, it will be just like running an application on your system; Rails也是一个宝物 -意味着,如果您加载Rails控制台,它将就像在系统上运行应用程序一样; you won't be able to call any OS-level commands.
您将无法调用任何操作系统级别的命令。
bundle install
is like a control panel function - it installs the required gems for your Rails app, meaning you need to run it at OS-level, not rails level bundle install
就像控制面板功能一样-它为Rails应用安装必需的gem,这意味着您需要在OS级别而不是Rails级别运行它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.