Rails gems和bundle的问题

时间:2018-06-02 16:16:41

标签: ruby-on-rails ruby

我有一个使用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)

1 个答案:

答案 0 :(得分:0)

在计算机的.bash_profile或.zshrc中为zsh设置bundle exec的别名。

.map(Student::new)

然后运行代码将是这样的:

alias be='bundle exec' to .bash_profile or .zshrc 

或查看binstubs:https://bundler.io/v1.7/bundle_binstubs.html