我有一个使用ruby "~> 2.4.2“的新Rails 5.0.2项目。
我可以启动服务器并在本地处理项目。
然而,我只是试图生成一个模型,却遇到了一些我不理解的奇怪行为。
rails g model Sensor
/Users/brianrhea/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/spec_set.rb:88:in `block in materialize': Could not find nokogiri-1.8.2 in any of the sources (Bundler::GemNotFound)
因此,我运行bundle
并确认已经安装了Using nokogiri 1.8.2
。
所以,我运行了gem install nokigiri
,它安装得很好,然后我这样做了:
rails g model Sensor
/Users/brianrhea/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.1/lib/bundler/spec_set.rb:88:in `block in materialize': Could not find pg-0.21.0 in any of the sources (Bundler::GemNotFound)
好了,现在它在抱怨pg
,所以我做了gem install pg-0.21.0
然后运行rails g model Sensor
,它起作用了。
知道这是怎么回事吗?我是不是把这个项目搞糊涂了,不知道到哪里去寻找它的精华?
编辑:
对于其他上下文,当我运行rails new project_name
时,我得到以下错误:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'rails-dom-testing' (~> 2.0) - did find: [rails-dom-testing-1.0.9,rails-dom-testing-1.0.7] (Gem::LoadError)
发布于 2018-06-03 21:50:00
在zsh的计算机.bash_profile或.zshrc中为bundle exec设置别名。
alias be='bundle exec' to .bash_profile or .zshrc
然后运行代码,如下所示:
be rails g model
https://stackoverflow.com/questions/50658842
复制相似问题