Bundler的新鲜红宝石 - 无法加载我的version.rb文件? [英] Fresh Ruby gem from Bundler - cannot load my version.rb file?

查看:72
本文介绍了Bundler的新鲜红宝石 - 无法加载我的version.rb文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个新的Ruby应用程序,所以我决定使用 bundle gem foo 来完成它。这给了我整个:

  lib / 
foo /
version.rb
foo .rb
Gemfile
Rakefile
foo.gemspec
README.md

结构。现在当我运行 ruby​​ foo.rb 时,我得到了:

 ` require':无法加载这样的文件 -  foo / version(LoadError)

foo.rb只是默认值:

$ $ p $ require'foo / version'

module Foo
end

宝石是不是可以自行运行?我希望我不必将我的宝石包含到示例应用程序中来测试它? 您需要运行 bundle exec ruby​​ foo.rb 使用捆绑的宝石。

或者,您可以修改 foo.rb 来假定Bundler。只要把

  require'bundler / setup'

在顶部。


I wanted to make a fresh Ruby app, so I decided to use bundle gem foo to do it. This gave me the whole:

lib/
  foo/
    version.rb
  foo.rb
Gemfile
Rakefile
foo.gemspec
README.md

structure. Now when I run ruby foo.rb, I get:

`require': cannot load such file -- foo/version (LoadError)

foo.rb is just the default:

require 'foo/version'

module Foo
end

Can gems not be ran on their own? I hope I don't have to include my gem into a sample app just to test it out?

解决方案

You need to run bundle exec ruby foo.rb to use Bundled gems.

Alternatively, you can modify foo.rb itself to assume Bundler. Just put

require 'bundler/setup'

at the top.

这篇关于Bundler的新鲜红宝石 - 无法加载我的version.rb文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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