I am currently developing a standalone ruby application alongside a Rails application that works as its frontend. I am managing the dependencies of the Ruby app with Bundler, so there are two gemfiles.
我目前正在开发一个独立的ruby应用程序,以及一个作为前端工作的Rails应用程序。我正在使用Bundler管理Ruby应用程序的依赖项,因此有两个gemfile。
I have a problem trying to execute the Ruby application from the Rails frontend via a system call to a rake task.
我有一个问题,通过系统调用rake任务从Rails前端执行Ruby应用程序。
When I call the rake task from a standard IRB, it works; but if I try to call the task from a Rails controller or the rails console, dependency issues arise.
当我从标准的IRB中调用rake任务时,它是有效的;但是,如果我试图从Rails控制器或Rails控制台调用任务,就会出现依赖性问题。
As a workaround I can add all the gems not present in the Rails application to the Rails Gemfile, but I guess this approach is wrong.
作为一种解决方案,我可以将Rails应用程序中没有的所有gem添加到Rails Gemfile中,但是我认为这种方法是错误的。
I think it might be a problem with the scope of Bundler. How could I work around this problem?
我认为这可能是一个问题,在范围的Bundler。我如何解决这个问题?
Thanks.
谢谢。
1 个解决方案
#1
2
fork do
Dir.chdir("/your/project/dir")
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', __FILE__)
Bundler.setup
exec "rake -T"
end
#1
2
fork do
Dir.chdir("/your/project/dir")
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', __FILE__)
Bundler.setup
exec "rake -T"
end