我正在尝试从控制器中的rake任务中捕获输出,如下所示:
buffer = []
Open3.popen3("rake namespace:task") do |stdin, stdout, stderr|
begin
while line = stdout.readline
buffer << line
end
rescue
end
end
但是,该任务永远不会执行。而且没有输出。我尝试了很多其他命令,一切正常。请问有人帮帮我吗?
非常感谢任何帮助!
更新1
stderr内容:
/home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/source/git.rb:191:in `rescue in load_spec_files': git://github.com/activescaffold/active_scaffold.git (at master) is not yet checked out. Run `bundle install` first. (Bundler::GitError)\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/source/git.rb:188:in `load_spec_files'\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/source/path.rb:92:in `local_specs'\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/source/git.rb:159:in `specs'\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/lazy_specification.rb:53:in `__materialize__'\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/spec_set.rb:88:in `block in materialize'\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in `map!'\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in `materialize'\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/definition.rb:140:in `specs'\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/definition.rb:185:in `specs_for'\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/definition.rb:174:in `requested_specs'\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/environment.rb:18:in `requested_specs'\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/runtime.rb:13:in `setup'\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler.rb:127:in `setup'\n", "\tfrom /home/adam/.rvm/gems/ruby-2.2.1/gems/bundler-1.10.6/lib/bundler/setup.rb:18:in `<top (required)>'\n", "\tfrom /home/adam/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'\n", "\tfrom /home/adam/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'\n"
答案 0 :(得分:0)
将源gems.gthub.com
添加到Gemfile解决了我的问题。