Ruby-on-rails 瑞克中止!没有这样的文件来加载 --bundler/setup Rails 3.1
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7483515/
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
Rake aborted! no such file to load --bundler/setup Rails 3.1
提问by Juanito Fatas
I am very new in Rails. after I created a new rails project.
我是 Rails 的新手。在我创建了一个新的 rails 项目之后。
rails new test project
I ran
我跑了
rake db:create
In order to create a database. Found the following error message:
为了创建数据库。发现以下错误信息:
rake aborted!
no such file to load -- bundler/setup
I am running
我在跑步
Rails 3.1.0
导轨 3.1.0
Ruby 1.9.2p290
红宝石 1.9.2p290
rvm 1.8.3
房车 1.8.3
Thank you very much!
非常感谢!
my $PATH /Users/Mac/.rvm/scripts/rvm:/Users/Mac/.rvm/bin:/Users/Mac/.local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:{ANT_HOME}/bin
我的 $PATH /Users/Mac/.rvm/scripts/rvm:/Users/Mac/.rvm/bin:/Users/Mac/.local/bin:/opt/local/bin:/opt/local/sbin:/ usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:{ANT_HOME}/bin
回答by lemoncider
Run:
跑:
gem install bundler
bundle install
bundle exec rake db:create
You might want to learn about Bundler.
您可能想了解Bundler。
See the link on "Creating new Rails Project".
请参阅“创建新的 Rails 项目”上的链接。
回答by jpw
I had the same thing and here's what I found: You probably have more than one version of rake installed (type gem listto see), and your project is specifying you must use the older version of rake.
我有同样的事情,这是我发现的:您可能安装了多个版本的 rake(键入gem list查看),并且您的项目指定您必须使用旧版本的 rake。
If you do, then the default rake is the newer one.
如果您这样做,则默认耙子是较新的耙子。
If you are in your project directory, and your project's Gemfile specifies the older version of rake, and your type rake db:migrate then the error message is telling you that the 'new' version of rake is not the one you specified in Gemfile, so run bundle exec rake db:migrateso bundler can pick the correct version of rake for you.
如果您在您的项目目录中,并且您的项目的 Gemfile 指定了旧版本的 rake,并且您的类型是 rake db:migrate,那么错误消息会告诉您“新”版本的 rake 不是您在 Gemfile 中指定的版本,所以运行,bundle exec rake db:migrate以便bundler可以为您选择正确版本的rake。
回答by Krystian
I just had the same issue. I didn't solve it fully but by running:
我只是有同样的问题。我没有完全解决它,而是通过运行:
bundle exec rake <task>
I was able to finally run the task I wanted without the error you have.
我终于能够运行我想要的任务,而不会出现您遇到的错误。
回答by Saifis
try
尝试
gem install bundler
bundle install
宝石安装捆绑器
捆绑安装
to install the gems needed.
安装所需的宝石。
rake tasks will fail if you do not have the gems necessary for the rails app.
如果您没有 Rails 应用程序所需的 gem,则 rake 任务将失败。
回答by Romain
Have you tried to gem install bundler? I'd be surprised it doesn't install when you install the rails gem, but it seems that's your issue...
你试过gem install bundler吗?当您安装 rails gem 时它没有安装,我会感到惊讶,但这似乎是您的问题......
回答by neoneye
I got the same error as you while upgrading a non-rails project from Ruby 1.8.x to Ruby 1.9.x. The problem is that the current dir has been removed from LOAD_PATH.
在将非 Rails 项目从 Ruby 1.8.x 升级到 Ruby 1.9.x 时,我遇到了与您相同的错误。问题是当前目录已从 LOAD_PATH 中删除。
Why does Ruby 1.9.2 remove “.” from LOAD_PATH, and what's the alternative?
为什么 Ruby 1.9.2 删除了“.” 来自 LOAD_PATH,还有什么选择?
I had to change a few places from requireto require_relativeand then it worked.
我不得不将一些地方从 更改require为require_relative,然后它起作用了。
回答by calasyr
Got the same missing bundler message running rake after upgrading to Ruby 1.9.2.
升级到 Ruby 1.9.2 后,运行 rake 时出现相同的丢失捆绑器消息。
Rake needed updating and bundler needed to be reinstalled:
Rake 需要更新并且需要重新安装 bundler:
sudo gem update rake
须藤宝石更新耙
sudo gem install bundler
sudo gem 安装捆绑器
Reinstalling bundler might have fixed the error, but you want to make sure rake is right too.
重新安装 bundler 可能已经修复了错误,但您也想确保 rake 是正确的。
回答by José Fernandes
I'm using Snow Leopard, had a similar problem recently. It happens that, for some reason, a system update created a hard link at /usr/bin/rake, pointing to OSX default 1.8 ruby environment rake executable. My 1.9 ruby installation is at /usr/local/bin, which comes later on my PATH setting, so when I ran "ruby -v" I got what I expect, same with "gem environment", but rake tasks were failing in the way you describe.
我正在使用雪豹,最近遇到了类似的问题。碰巧,出于某种原因,系统更新在 /usr/bin/rake 创建了一个硬链接,指向 OSX 默认的 1.8 ruby 环境 rake 可执行文件。我的 1.9 ruby 安装位于 /usr/local/bin,它在我的 PATH 设置中稍后出现,所以当我运行“ruby -v”时,我得到了我所期望的,与“gem environment”相同,但是 rake 任务在你描述的方式。
I just deleted the entry /usr/bin/rake. Moving /usr/local/bin up on PATH might've worked too. The result of running "which rake" must point to your 1.9 installation.
我刚刚删除了 /usr/bin/rake 条目。在 PATH 上移动 /usr/local/bin 可能也有效。运行“which rake”的结果必须指向您的 1.9 安装。
Hope it helps,
希望能帮助到你,
-- José
——何塞

