简体   繁体   English

来自Bundler的新鲜Ruby gem - 无法加载我的version.rb文件?

[英]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.

相关问题 Ruby gem中version.rb的好处是什么? - What's the benefit of version.rb in Ruby gem 在$ RUBY_HOME / ruby​​gems / version.rb文件上运行gem时,“无法修改冻结的字符串” - “can't modify frozen string” when running gem on file $RUBY_HOME/rubygems/version.rb Bundler +新的gem:无法加载此类文件-仆从/版本(LoadError) - Bundler + new gem: cannot load such file — minion/version (LoadError) 从Ruby内部使用bundler验证gem的版本 - Verify version of a gem with bundler from inside Ruby 带有@global gem的Ruby / RVM - bundle运行失败,带有`require':无法加载这样的文件 - bundler(LoadError) - Ruby/RVM with @global gem - bundle run fails with `require': cannot load such file — bundler (LoadError) Ruby脚本无法加载通过捆绑程序安装的gem - Ruby script cannot load a gem installed via bundler RubyMine / IDEA ruby​​调试器无法在bundler模​​式下加载linecache gem - RubyMine/IDEA ruby debugger cannot load linecache gem in bundler mode Ruby错误kernel_require.rb:55:在'require'中:无法加载此类文件— ec2 / amitools / version - Ruby error kernel_require.rb:55:in `require': cannot load such file — ec2/amitools/version "Ruby 需要 - 无法加载这样的文件 - 我自己的 gem" - Ruby require - cannot load such file - my own gem Ruby Bundle安装不需要的Puppet Gem版本 - Ruby bundler installing unwanted version of puppet gem
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM