0

运行此命令时出现此错误 rails g mongoid:config. 有没有人有任何想法

/home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/byebug-3.5.1/lib/byebug/history.rb:1:in `require': cannot load such file -- readline (LoadError)
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/byebug-3.5.1/lib/byebug/history.rb:1:in `<top (required)>'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/byebug-3.5.1/lib/byebug/interface.rb:1:in `require'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/byebug-3.5.1/lib/byebug/interface.rb:1:in `<top (required)>'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/byebug-3.5.1/lib/byebug/core.rb:5:in `require'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/byebug-3.5.1/lib/byebug/core.rb:5:in `<top (required)>'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/byebug-3.5.1/lib/byebug.rb:1:in `require'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/byebug-3.5.1/lib/byebug.rb:1:in `<top (required)>'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/runtime.rb:76:in `require'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/runtime.rb:72:in `each'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/runtime.rb:72:in `block in require'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/runtime.rb:61:in `each'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/runtime.rb:61:in `require'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler.rb:134:in `require'
    from /home/gardezi/blog/config/application.rb:7:in `<top (required)>'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/spring-1.3.3/lib/spring/application.rb:82:in `require'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/spring-1.3.3/lib/spring/application.rb:82:in `preload'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/spring-1.3.3/lib/spring/application.rb:143:in `serve'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/spring-1.3.3/lib/spring/application.rb:131:in `block in run'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/spring-1.3.3/lib/spring/application.rb:125:in `loop'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/spring-1.3.3/lib/spring/application.rb:125:in `run'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/spring-1.3.3/lib/spring/application/boot.rb:18:in `<top (required)>'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/gardezi/.rbenv/versions/2.1.5/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'

我运行的命令如下:

宝石安装 mongoid

导轨新博客

gedit /blog/Gemfile 我在其中写了 gem 'mongoid', '4.0.2' gem 'bson_ext'

然后我跑了 bundle

然后是 rails g mongoid:config

多亏了 Shweta,rails g 命令现在没有给出错误,但现在我遇到了另一个问题,那就是当我运行这个命令时,它会在无限循环中运行。已经七个小时了,还在运行,所以请告诉我该怎么办。

提前致谢

4

2 回答 2

4

我解决了这个问题。我只需要停止春天。

于 2015-03-01T04:40:50.663 回答
0

请按照以下步骤操作:

1] 创建新项目时跳过活动记录

rails new blog -O

2] 打开 Gemfile 添加 gem 'mongoid'。无需添加 gem 'bson_ext'

gem 'mongoid'

3]安装包

bundle install

4]生成mongoid配置文件

rails g mongoid:config

希望这可以帮助。

于 2015-02-27T17:17:43.440 回答