美文网首页
安装Rails遇到的问题

安装Rails遇到的问题

作者: 秋天的田野 | 来源:发表于2019-03-04 16:31 被阅读0次

进入项目,启动server模式,执行命令

rails s

打开http://localhost:3000
报错

Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

需要重新安装Ruby,指定正确的版本号
首先查看系统已安装的Ruby,执行命令

rvm list
   ruby-2.3.0 [ x86_64 ]
=* ruby-2.3.1 [ x86_64 ]
   ruby-2.3.8 [ x86_64 ]
# => - current
# =* - current && default
#  * - default

可以看到有三个ruby,先全部卸载
分别执行命令

rvm uninstall 2.3.0
rvm uninstall 2.3.1
rvm uninstall 2.3.8

查找最新的ruby版本,如我现在找到的是2.6.1,执行命令

rvm install 2.6.1

安装完成后,执行命令

rvm use 2.6.1 --default

然后执行命令,查看目前已安装的ruby版本

rvm list

安装Rails,执行命令

gem install rails

将安装rails的最新版本
打开http://localhost:3000报错提示Gamfile文件中缺少sqlite3 1.3.6时,打开Gamfile文件,找到

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

修改为

# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.3.6'

然后再次执行

bundle install

相关文章

网友评论

      本文标题:安装Rails遇到的问题

      本文链接:https://www.haomeiwen.com/subject/dnyiuqtx.html