如何解决无法在 Rails 中生成用户模型
在 MimeMagic 依赖失败之后,我现在无法在 Rails 中生成模型。尝试在 rails 中生成用户模型后,我收到以下警告消息和堆栈跟踪错误
import os
import requests
import ftplib
from ftplib import FTP
import random
client = discord.Client()
ftp = FTP()
ftp.connect(os.getenv('BOP_IP'),2021)
ftp.login(os.getenv('BOP_UN'),os.getenv('BOP_PW'))
#path='/'
@client.event
async def on_ready():
print('We have logged in as {0.user}'
.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$gimme'):
await message.channel.send(#######)
client.run(os.getenv('TOKEN'))
然而,我的 Gemfile 更新到 2.2.15,我再次运行 bundle install 无济于事。
这是警告之后的堆栈跟踪错误的一部分:
rails generate model User email:string
password_digest:string
Warning: the running version of Bundler (2.2.3) is
older than the version that created the lockfile
(2.2.15). We suggest you to upgrade to the version
that created the lockfile by running `gem install
bundler:2.2.15`.
解决方法
用于生成 Gemfile 的 bundler 是全局安装在 ruby gems 目录中的那个。
gem environment
和
gem list
将为您提供有关当前 ruby 和 gems 安装的更多信息。
您可能将旧版本的 bundler 添加到 gemfile 中,并使用 bundle
命令切换到旧版本。
您可以尝试通过运行提示的方式更新 bundler 的全局版本
gem install bundler:2.2.15
在我看来,您应该从 gemfile 中删除 bundler 条目,因为每次使用 bundle
命令时,它都会不必要地切换回旧版本。