我正在尝试将MySQL作为数据库创建一个项目,RAN命令
rails new project_name -d mysql
获得以下错误,
无法在本地安装的GEM中找到GEM“ mySQL2(〜> 0.5)”。 Rails ImportMap:安装
无法在本地安装的宝石中找到GEM“ mySQL2(〜> 0.5)”。运行捆绑安装
以安装缺少的宝石。
Rails Turbo:安装刺激:安装在本地安装的宝石中找不到GEM'MySQL2(〜> 0.5)'。
运行捆绑安装
以安装缺少的宝石。 “
所以我跑了,
bundle install
但是失败了,最后告诉我
安装MySQL2(0.5.4)时发生了错误,而Bundler无法继续
完全错误 https://pastebin.com/jix7v0z0
我正在运行Windows(我发现的所有答案均用于Linux或Mac),任何帮助都会赞赏
Edit :作为Christos- Angelos Vasilopoulos提到,在本期中回答
我所做的是前两个步骤
1-启动一个CMD终端并通过运行明确运行RIDK:
c:\ ruby31-x64 。
启用
ridk.cmd
/您通往Ruby31-X64/MSYS64/Mingw64 的路径
(没有任何特定的报价被拒绝,我使用了前斜线)。
I'm trying to create a project with mysql as a database, ran command
rails new project_name -d mysql
got the following errors
Could not find gem 'mysql2 (~> 0.5)' in locally installed gems. rails importmap:install
Could not find gem 'mysql2 (~> 0.5)' in locally installed gems. Run bundle install
to install missing gems.
rails turbo:install stimulus:install Could not find gem 'mysql2 (~> 0.5)' in locally installed gems.
Run bundle install
to install missing gems. "
so i ran
bundle install
but it fails and at the end it tells me
An error occurred while installing mysql2 (0.5.4), and Bundler cannot continue
full error https://pastebin.com/jiX7V0Z0
I'm running windows (all answers I found were for linux or mac), any help is appreciated
Edit : as Christos-Angelos Vasilopoulos mentioned, answer in this issue worked https://github.com/brianmario/mysql2/issues/1210#issuecomment-965862944
what I did was the first two steps
1 - Start a cmd terminal and run ridk explicitely by running:
c:\your path to Ruby31-x64\ridk_use\ridk.cmd enable
.
This gives you the right environment to do the rest.
2 - From that cmd, run
gem install mysql2 --platform=ruby -- --with-mysql-dir=c:/your path to Ruby31-x64/msys64/mingw64
(no particular quote was neeeded and I used forward slashes).
发布评论
评论(6)
尽管有解决方法,但这是MySQL2的一个空缺问题。检查此 thread 来自Github。此注释您需要解决问题。
It is an open issue with mysql2 though there is a workaround. Check this thread from GitHub. This comment is the thing you need to resolve the problem.
在Ubuntu中运行
Bundle install
时,我会遇到类似的问题。我通过安装以下依赖关系解决了问题。sudo apt-get安装libmysqlclient-dev
。这对Linux用户可能会有所帮助。
I run into similar issues installing mysql2 when running
bundle install
in Ubuntu. I solved the problem by installing the following dependencies.sudo apt-get install libmysqlclient-dev
.This could be helpful for Linux users.
使用:
Ruby -v = 3.2.2&
导轨-v = 7.1.3.3
using:
ruby -v= 3.2.2 &
Rails -v= 7.1.3.3
请尝试:
please try:
在窗户上安装导轨后,从以下链接和安装下载 mysql 5.5 32bits 。
https://dev.mysql.com/downloads/downloads/mysql/mysql/5.5.5.5.html
(我下载了'Windows(x86,64位),zip存档',然后将其粘贴到我的C驱动器中,如 mysqlconn 。 > to 路径框)。
之后,通过使用以下命令将其安装在命令窗口中:
然后将 c:\ mysqlConn \ lib 在Ruby bin Folder 中找到 libmysql.dll C:\ ruby32-x64 \ bin
after install rails on your Windows, download mysql 5.5 32bits from following link and install.
https://dev.mysql.com/downloads/mysql/5.5.html
(I downloaded 'Windows (x86, 64-bit), ZIP Archive' and pasted it to my C drive as mysqlconn. You can use MSI Installer and configure Add Mysql Bin Folder to PATH box).
After that install the gem in a command window by using following command:
Then copy the libmysql.dll found in C:\mysqlconn\lib to your ruby bin folder C:\Ruby32-x64\bin
对于Almalinux/RH/Centos/Rocky上的那些:您只需通过DNF安装宝石:
对我来说是窍门。还有更多的宝石,只需搜索
For those on Almalinux/RH/CentOS/Rocky: you can just install the gems via dnf:
Dit the trick for me. There are a lot of more gems available, just search with