如何在捆绑程序上下文中运行ruby脚本? [英] How to run a ruby script within bundler context?

查看:62
本文介绍了如何在捆绑程序上下文中运行ruby脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为foo.rb的Ruby脚本,我想在捆绑程序环境的上下文中运行它。

I have a Ruby script called foo.rb, and I want to run it within the context of the bundler environment. How?

捆绑exec foo.rb 不起作用,因为exec需要一个shell脚本。

bundle exec foo.rb doesn't work, because exec expects a shell script.

推荐答案

将脚本名称传递给 ruby​​ 命令:

Pass the script name to the ruby command:

bundle exec ruby script_name

如果您还想要Rails环境:

If you also want the Rails environment:

bundle exec rails runner script_name

这篇关于如何在捆绑程序上下文中运行ruby脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆