创建项目时如何让 Rails 使用最新安装的 ruby 版本?
Ruby 和 Rails 新手,我在设置时遇到了障碍。我使用MacPorts安装了Ruby,然后使用gem安装了rails。它们似乎都是正确的版本:
$ ruby --version
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11]
$ rails --version
Rails 3.1.1
但是,为什么我用“rails new demo”制作了一个演示 Rails 应用程序,然后用“rake about”查看它,看起来 ruby 版本仍然是 1.8:
About your application's environment
Ruby version 1.8.7 (universal-darwin11.0)
RubyGems version 1.8.11
Rack version 1.3
Rails version 3.1.1
我已经验证了我的 $PATH 早期有一个符号链接指向我想要的 ruby 版本(/opt/local/bin)。如何让 Rails 使用 ruby 1.9?谢谢
New to Ruby and Rails, and I'm hitting a snag getting set up. I installed Ruby with MacPorts, then used gem to install rails. They both appear to be the correct versions:
$ ruby --version
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11]
$ rails --version
Rails 3.1.1
However, whey I make a demo rails app with 'rails new demo' and then take a look at it with 'rake about', it looks like the ruby version is still 1.8:
About your application's environment
Ruby version 1.8.7 (universal-darwin11.0)
RubyGems version 1.8.11
Rack version 1.3
Rails version 3.1.1
I have verified that i have a symlink early in my $PATH pointing to the version of ruby I want (/opt/local/bin). How do I get rails to use ruby 1.9? thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您从 macports 卸载 ruby 并尝试使用 RVM 进行安装。
http://beginrescueend.com/
关于您的问题,可能是Bundler执行系统的路径问题rake 命令而不是捆绑器。
尝试运行bundle exec rake about 看看会发生什么。
I recommend you uninstall ruby from macports and try to do an installation using RVM instead.
http://beginrescueend.com/
In regards of your problem, it may probably be a path issue with Bundler executing the system rake command instead of the bundler.
Try running bundle exec rake about and see what happens.
实际上我很确定这与 macports 版本本身无关。
您可能更改了 ruby 本身的符号链接,但是您更改了 rubygems 的符号链接吗?
又名是
gem --version
和gem1.9 --version
都指向同一版本?因为如果没有,您可能已经安装了 ruby1.8 的 Rails。例如在我的系统上:
Snow Leopard 标准 1.8 版本:
MacPorts 1.9 版本(已更名):
actually i'm pretty sure that this isn't about the macports version per se.
You may have change the symlink for ruby itself, but did you change the symlink for rubygems?
a.k.a are
gem --version
andgem1.9 --version
both pointing to the same version? Because if not you´ve probably installed rails for ruby1.8.For example on my System:
Snow Leopard standard 1.8 version:
MacPorts 1.9 Version(already renamed):