LoadError:无法在rake db:create上加载此类文件-mysql2 / mysql2-

时间:2019-07-10 18:53:22

标签: mysql ruby-on-rails

运行rake db:create时出现此错误:

LoadError: cannot load such file -- mysql2/mysql2
/Users/vitorqueiroz/dev/pipeline/config/application.rb:10:in `<top (required)>'
/Users/vitorqueiroz/dev/pipeline/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)

我必须手动安装mysql2 gem,因为gemfile指定了版本'0.3.20'

我跑了 gem install mysql2 -v '0.3.20' -- --srcdir=/usr/local/include/mysql

捆绑安装运行正常,并且说一切都已安装。

bundle list mysql2的计算结果为:

/Users/vitorqueiroz/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/mysql2-0.3.20

-

还有其他选择吗?

1 个答案:

答案 0 :(得分:0)

您可以尝试

bundle exec rake db:create

确保已装入捆绑的宝石。

https://bundler.io/man/bundle-exec.1.html