[英]Fresh Ruby gem from Bundler - cannot load my version.rb file?
I wanted to make a fresh Ruby app, so I decided to use bundle gem foo
to do it. 我想制作一个新的Ruby应用程序,所以我决定使用
bundle gem foo
来做它。 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: 现在,当我运行
ruby foo.rb
,我得到:
`require': cannot load such file -- foo/version (LoadError)
foo.rb is just the default: foo.rb只是默认值:
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. 你需要运行
bundle exec ruby foo.rb
才能使用Bundled gems。
Alternatively, you can modify foo.rb
itself to assume Bundler. 或者,您可以修改
foo.rb
本身以假设Bundler。 Just put 刚刚放
require 'bundler/setup'
at the top. 在顶部。
What directory are you running that from? 你从哪个目录运行? I would check your $LOAD_PATH and ensure lib is included in it.
我会检查你的$ LOAD_PATH并确保包含lib。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.