第一次安装rails,帮助gems / rake

时间:2010-02-19 20:53:08

标签: ruby-on-rails rubygems rake

我刚做了第一次ruby企业版,安装了一些宝石,现在我正在尝试做一个  'sudo ./rake gems:install'并获得:

耙子中止了!
找不到Rakefile

错误。首先,我应该从哪个目录中做到这一点?

以下是我遵循的步骤:
http://www.rubyenterpriseedition.com/download.html下载ruby企业  wget http://rubyforge.org/frs/download.php/68719/ruby-enterprise-1.8.7-2010.01.tar.gz

./红宝石企业X.X.X /安装

/opt/ruby-enterprise-1.8.7-2010.01/bin/gem install mysql

ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/gem / usr / bin / gem
 ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/rake / usr / bin / rake

我安装了几个宝石

我找到了合适的目录(我认为),但仍然遇到错误。这是rake的副本:--trace:

dan@dev:~/myApp.com-ror$ rake --trace gems:install
(in /home/dan/myApp.com-ror)                      
** Invoke gems:install (first_time)                  
** Invoke gems:base (first_time)                     
** Execute gems:base                                 
** Invoke environment (first_time)                   
** Execute environment                               
rake aborted!                                        
No such file or directory - /home/dan/myApp.com-ror/config/database.yml                                                    
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:902:in     `read'                                  
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:902:in  `database_configuration'                
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:437:in `initialize_database'                   
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:141:in `process'                               
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `send'                                  
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `run'                                   
/home/dan/songness.com-ror/config/environment.rb:14            
/home/dan/Languages/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in  `gem_original_require'                       
/home/dan/Languages/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'                                    
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'       
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'                                                             
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'       
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/misc.rake:4                                             
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'                                          
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'                                       
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'                                          
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'                                       
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'                        
/home/dan/Languages/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'                                                         
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'                        
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'                                        
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/gems.rake:17                                            
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'                                          
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'                                       
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'                                          
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'                                       
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'                        
/home/dan/Languages/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'                                                         
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'                        
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'                          
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'                                          
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'                          
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'                         
/home/dan/Languages/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'                                                         
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'                        
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'                                        
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'                                  
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'                                    
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

database.yml应该是什么样的?

4 个答案:

答案 0 :(得分:4)

rake gems:install是为您的应用安装宝石。您必须在应用程序根目录中运行它。要在您的计算机上安装gem,请使用gem install

答案 1 :(得分:0)

如果您没有正确设置路径,则需要从rails目录运行它。

答案 2 :(得分:0)

好的,我查看了文档

$ /opt/ruby-enterprise-X.X.X/bin/gem install rails

在你的情况下意味着:

gem install rails

当你提到'sudo ./rake gems:install'你想要实现什么目标?

安装导轨后:

rails myproject

你去吧。

答案 3 :(得分:0)

假设你没有使用bundler或者不能(因为你的ruby / rails版本)......


下面,我避免使用 sudo prepend,因为RoR不再是linux用户的唯一领域。使用gitbash作为我们的低级控制台在本地开发环境中管理我们的Rails应用程序的Windows用户不需要 sudo ,也不会在我们的开发环境中工作。 FTR,如果你不知道sudo是什么,它意味着“超级用户做”,来自unix的剩余部分,因此是linux白话的固有部分。如果你需要在Linux中做需要特权的事情,你可能需要sudo来获得这些权利(或者你需要为自己的特定行动分配直接的超级用户状态....有时sudo是不够的! )。如果你需要在Windows中拥有权限,你可能已经登录了具有管理权限的窗口。无论如何,如果你是Ruby on Rails的新手并且被这个术语混淆了,那么现在就忽略它。你不需要它,虽然你可能会在某些时候开始与托管服务进行交互,托管服务通常在linux框架内运行......


无论如何,回到手头的问题......

gem install(某些宝石名称)(例如:gem install tinyMCE)将副本安装到本地Ruby开发环境中。也就是说,将其视为安装您稍后可以调用的库组件。一般来说,它本身对我们的应用程序没有任何作用。

但是如果你想使用一个gem(第二个源增强包,例如:tinyMCE,一个流行的富文本编辑器增强版),那么gem需要直接安装到你的应用程序,或者说另一种方式,你会需要在将应用程序安装到rails开发环境之后将可传输副本绑定到应用程序,无论是修改现有应用程序还是创建新应用程序。

如果你仍然感到困惑,假设我是这样说的

您创建了一个类似“My_special_blog”的应用程序。操作 Rails My_special_blog 创建基本管道,但它不会编写内容,也不会自动安装tinyMCE以便您可以使用它,即使您已将其安装到开发系统中(使用 gem install tinyMCE ),即您的RUBY安装。 Gems是一种添加功能的简单方法,如前面提到的富文本编辑器

这正是 rake:gems install 的确如此。它使用你的应用程序的environment.rb文件(在 My_special_blog / config子目录 btw中)来确定应用程序需要使用哪些gem,然后将它们安装到应用程序中(字面意思是在子目录中)来自本地开发环境的My_special_blog / vendors目录。

重要的是,当你运行rake:gems install时,你需要从应用程序的“root”,即从My_special_blog目录执行。不是ruby目录,不是My_special_blog / config,只是My_special_blog(作为示例应用程序名称)

作为领导者,您可以进行一些谷歌搜索......可以在environment.rb的 config.gem 语句中指定版本和源位置,这些语句定义您将使用哪些宝石

希望这能帮助那些喜欢我的人经常被简短的答案所困惑,这些答案假设一个人已经足够专业,而且首先不会问这个问题......


如果你看一下environment.rb,它应该有这样的条目

Rails :: Initializer.run do | config |

它位于初始化程序中,您放置了gem配置语句。例如,假设您想要添加清除宝石,您需要v0.5.3并且宝石位于gems.github.com ...并且您还希望mislav-will paginate,语法可能看起来像这样:

Rails::Initializer.run do |config|

    config.gem "thoughtbot-clearance",
        :lib => 'clearance',
        :source => 'http://gems.github.com',
        :version => '0.5.3'

    config 'mislav-will_paginate',
        :version => '~> 2.3.8',
        :lib => 'will_paginate',
        :source => 'http://gems.github.com'

end

没有这些语句,rake:gems install不会将这些gem的本地副本加载到应用程序的vendor / gems文件夹中。