我刚刚创建了一个名为maker的示例gem。我也在使用RVM。
最近添加示例用户功能的更改出现在this PR中。我一直在Bundler文档中遵循this guide来创建一个新的gem。
我目前正在尝试通过irb使用gem,当我执行require maker
时,我得到以下错误:
:001 > require 'maker'
LoadError: cannot load such file -- maker/user
from /Users/mohnishgj/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/mohnishgj/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/mohnishgj/.rvm/gems/ruby-2.4.1@experiments/gems/maker-0.1.0/lib/maker.rb:2:in `<top (required)>'
from /Users/mohnishgj/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `require'
from /Users/mohnishgj/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
from /Users/mohnishgj/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from (irb):1
from /Users/mohnishgj/.rvm/rubies/ruby-2.4.1/bin/irb:11:in `<main>'
:002 >
当我导航到experiments
gem集(即/Users/mohnishgj/.rvm/gems/ruby-2.4.1@experiments/gems/maker-0.1.0
)安装gem的位置时,我清楚地看到该位置缺少user.rb
文件。
/Users/mohnishgj/.rvm/gems/ruby-2.4.1@experiments/gems/maker-0.1.0/lib/maker
➜ maker ls
version.rb
每当我想添加新文件作为gem的一部分并希望它在irb
之外工作时,我该如何解决这个问题呢?我是否做了一些与宝石相关的开发错误?请原谅我的无知,我是一个相对较新的创造宝石。我应该如何正确地从源代码进行gem相关的开发?
此外,我可能会错过一些东西,但当我尝试添加Bundler.require(:default, :development)
到maker.gemspec(如guide to create the gem中所建议的)时,
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "maker/version"
Bundler.require(:default, :development)
我得到了如下错误:
[!] There was an error parsing `Gemfile`: - [!] There was an error while loading `maker.gemspec`: - [!] There was an error parsing `Gemfile`: - [!] There was an error while loading `maker.gemspec`: - [!] There was an error parsing `Gemfile`:
我能错过什么呢?
1条答案
按热度按时间r55awzrz1#
这个问题的答案是使用
bundle console
,如本文所述-http://wsmoak.net/2016/07/10/ruby-gem-dev-irb.html