macos Ruby、RVM、LLVM 和 MySQL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8000145/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:34:08  来源:igfitidea点击:

Ruby, RVM, LLVM and MySQL

ruby-on-railsrubymacosrvm

提问by MaltMaster

I'm having big trouble in configuring Ruby and MySQL on MacOSX. Just a fact, I'm new on MacOSX and Ruby On Rails.

我在 MacOSX 上配置 Ruby 和 MySQL 时遇到了大麻烦。事实上,我是 MacOSX 和 Ruby On Rails 的新手。

So, first I was having problems to install mysql2 gem, after get the gem installed I was trying developer a test, and when I tried start the WEBrick got this error saying that couldn't load a MySQL lib called "libmysqlclient.18.dylib". Googlin' about the error I saw that everyone was recommending using Ruby through RVM. I installed RVM and tried install ruby 1.9.3 and get this error:

所以,首先我在安装 mysql2 gem 时遇到问题,安装 gem 后我正在尝试开发人员测试,当我尝试启动时,WEBrick 收到此错误,说无法加载名为“libmysqlclient.18.dylib 的 MySQL 库” ”。Googlin' 关于我看到每个人都建议通过 RVM 使用 Ruby 的错误。我安装了 RVM 并尝试安装 ruby​​ 1.9.3 并收到此错误:

ERROR: The provided CC(/usr/bin/gcc) is LLVM based, it is not yet fully supported by ruby and gems, please read rvm requirements.

错误:提供的 CC(/usr/bin/gcc) 是基于 LLVM 的,ruby 和 gems 尚未完全支持它,请阅读rvm requirements

I'm almost giving up learn Rails, setup a development environment shouldn't be that painful. On Windows I got no problems.

我几乎要放弃学习 Rails,设置一个开发环境不应该那么痛苦。在 Windows 上我没有遇到任何问题。

[]'s Renan

[] 的雷南

回答by Delameko

Unfortunately, you're trying Rails at a bit of a bad time. There's a lot of transition at the moment, as others have mentioned Xcode 4.2 was recently released and has a new compiler, also Ruby 1.9.3 came out.

不幸的是,您正在尝试使用 Rails 的时机不太好。目前有很多转变,正如其他人提到的 Xcode 4.2 最近发布并有一个新的编译器,Ruby 1.9.3 也出来了。

I've been developing Ruby and Rails for some years now, but trying to get up and running again after installing Lion clean this week has been more problematic than in the past.

几年来我一直在开发 Ruby 和 Rails,但是在本周安装 Lion clean 后尝试重新启动并运行比过去更成问题。

First, make sure RVM is up to date (as the issue should be fixed):

首先,确保 RVM 是最新的(因为问题应该得到解决):

rvm get head

Then try installing like so:

然后尝试像这样安装:

CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared

EDIT:

编辑

Note, working through my own issues I believe the first command probably fixed the problem. The second wouldn't have provided any benefit over:

请注意,通过我自己的问题,我相信第一个命令可能解决了问题。第二个不会提供任何好处:

rvm install 1.9.3

As on my clean install, /usr/bin/gcc-4.2 doesn't exist.

在我的全新安装中, /usr/bin/gcc-4.2 不存在。

Also I wanted to add that I ended up compiling the older GCC manually for those situations where the new compiler fails. I followed this very informative blog post.

我还想补充一点,我最终手动编译了旧的 GCC,以应对新编译器失败的情况。我关注了这篇内容丰富的博客文章

回答by Anno2001

add --with-gcc=clangas a parameter:

添加--with-gcc=clang为参数:

rvm install ruby-1.9.3 --with-gcc=clang

回答by Cygnusx1

Did you install the latest Xcode from Mac Store?

您是否从 Mac Store 安装了最新的 Xcode?

here is a nice guide i followed to update my ruby/Rails to 1.9.2/3.0

这是我遵循的一个很好的指南,用于将我的 ruby​​/Rails 更新到 1.9.2/3.0

guide

指导

good luck

祝你好运

回答by Marnen Laibow-Koser

Part of the problem is that with Mac OS X 10.7 (Lion), Apple switched C compilers, and some things don't build well with the new (LLVM) compiler yet. See http://eddorre.com/posts/rails-ultimate-install-guide-on-os-x-lion-using-rvm-homebrew-and-powfor decent instructions (note: I haven't followed these exact instructions, but they're a pretty good summary of the things I diddo to get Rails working on Lion).

部分问题在于,在 Mac OS X 10.7 (Lion) 中,Apple 切换了 C 编译器,并且有些东西在新的 (LLVM) 编译器上还不能很好地构建。请参阅http://eddorre.com/posts/rails-ultimate-install-guide-on-os-x-lion-using-rvm-homebrew-and-pow以获取体面的说明(注意:我没有遵循这些确切的说明,但它们很好地总结了我为使 Rails 在 Lion 上工作所做的工作)。

Once you have the C compiler issue dealt with, everything else should be pretty effortless.

一旦你处理了 C 编译器的问题,其他的一切都应该很轻松。

Bonus tip: avoid MySQL. PostgreSQL is better in nearly every respect.

额外提示:避免使用 MySQL。PostgreSQL 在几乎所有方面都更好。

回答by brian.clear

Thanks Delamenko finally got it to work

谢谢德拉门科终于让它工作了

SUMMARY FOR STACK OVERFLOW

堆栈溢出的总结

I was trying to install SiriProxy on a clean Lion installation on Xcode from App Store

我试图从 App Store 在 Xcode 上的干净 Lion 安装上安装 SiriProxy

I kept getting errors like : The provided CC(/usr/bin/gcc) is LLVM based.

我不断收到错误,例如:提供的 CC(/usr/bin/gcc) 是基于 LLVM 的。

bash-3.2$ rvm install 1.9.3
ERROR: The provided CC(/usr/bin/gcc) is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`.

After 2 days finally got it working with these two lines

2 天后终于让它与这两条线一起工作

http://stackoverflow.com/questions/8000145/ruby-rvm-llvm-and-mysql

bash-3.2$ rvm get head
bash-3.2$ CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared

Before that I had tried every stackoverflow article on Ruby and Lion so doing these may have done some setup that helped the above 2 steps work:

在此之前,我已经尝试了所有关于 Ruby 和 Lion 的 stackoverflow 文章,因此这样做可能已经完成了一些有助于上述 2 个步骤工作的设置:

Things I tried included:

我尝试过的事情包括:

Running Install Xcode.app (I had downloaded from App Store - running this does futher installation)

运行安装 Xcode.app(我已经从 App Store 下载了 - 运行这个会进一步安装)

Installing

安装

https://github.com/kennethreitz/osx-gcc-installer/downloads may help for installing GCC.

Set up CC in

设置 CC

more /Users//.bash_profile

更多/用户//.bash_profile

bash-3.2$ more /Users/<USERNAME>/.bash_profile 
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
export CC=/usr/share/TargetConfigs/bin/gcc

First line came from SiriProxy install instruction https://github.com/plamoni/SiriProxy

第一行来自 SiriProxy 安装说明 https://github.com/plamoni/SiriProxy

2nd line export CC never seemed to work. So dont add.

第二行导出 CC 似乎从来没有工作过。所以不加。

It had many versions each pointing I finally used CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared

它有很多版本,每个指向我最终使用 CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared

回答by Adam Eberbach

See Arkku's answer- I tried everything here first, then did what he said and all is well.

请参阅Arkku 的回答- 我首先在这里尝试了所有方法,然后按照他说的做了,一切都很好。

As of Lion 10.7.3, Xcode 4.2 and Ruby 1.9.3p0 it's what works.

从 Lion 10.7.3、Xcode 4.2 和 Ruby 1.9.3p0 开始,它就是有效的。