简体   繁体   中英

First time rails install, help with gems/rake

I just did a first time ruby enterprise edition, installed some gems, and now I'm trying to do a
' sudo ./rake gems:install' and getting a:

rake aborted!
No Rakefile found

error. Firstly, what directory should I be doing this from?

Here are the steps I've followed:
download ruby enterprise from http://www.rubyenterpriseedition.com/download.html wget http://rubyforge.org/frs/download.php/68719/ruby-enterprise-1.8.7-2010.01.tar.gz

./ruby-enterprise-XXX/installer

/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

and I've installed several gems

I have found the appropriate directory (I think), and am still getting errors. Here's a copy of rake with --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

And what should database.yml look like?

rake gems:install is to install gems for your app. You have to run this inside your app root directory. To install gems on your machine use gem install .

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

Ok I've looked in the docs

$ /opt/ruby-enterprise-XXX/bin/gem install rails

in your case means just:

gem install rails

When you mentioned ' sudo ./rake gems:install' what were you trying to achieve?

Once installed rails do:

rails myproject

And there you go.

Presuming you're not using bundler or can't (due to your ruby/rails version)...


Below, I'm avoiding the sudo prepend because RoR is no longer the sole realm of linux users. Windows users using gitbash as our low level console for administering our Rails apps in the local development environment will not need sudo , nor will it work in our development environment. FTR, if you don't know what sudo is, it means "super user do", a leftover from unix and so an intrinsic part of the linux vernacular. If you need to do things in linux that require privilege, you'll probably need sudo to gain those rights (or you'll need to assign direct super user status to yourself for particular actions....sometimes sudo isn't enough!). If you need privilege in windows, you probably have already logged into windows with administrative rights.. In any case, if you're new to Ruby on Rails and are confounded by the term, just ignore it for now. You don't need it, although you probably will at some point when you start interacting with hosting services, which often run within a linux framework...


Anyway, getting back to the matter at hand...

gem install (some gem name) (ex: gem install tinyMCE) installs a copy to your local Ruby development environment. That is, think of it as installing a library component you can call on later. In general, it does nothing to our application on its own.

But if you want to use a gem (a second source enhancement package, ex: tinyMCE, a popular rich text editor enhancement) then the gem will need to be installed directly to your application, or said another way, you'll need to bind a transportable copy to the application AFTER installing it to your rails development environment, whetherr modifying an existing application or creating a new one.

If you're still puzzled, suppose I say it this way

you create an application like "My_special_blog". The action Rails My_special_blog creates the basic plumbing, but it doesn't write the content, nor does it automatically install tinyMCE so you can use it, even though you may have installed it to your development system (using gem install tinyMCE ), ie, your RUBY installation. Gems are an easy way of adding functionality like the aforementioned rich text editor

And that's exactly what rake:gems install does. It uses your application's environment.rb file (in the My_special_blog/config subdirectory btw) to determine which gems are wanted for use by the application, then it installs them to the application (literally, in subdirectories off the My_special_blog/vendors directory from the local development environment.

The important thing is that when you run rake:gems install, you need to do so from the "root" of your application, ie, from the My_special_blog directory. Not the ruby directory, not My_special_blog/config, just My_special_blog (as an example application name)

As a leader for you to do a bit of googling...Version and source location can be specified in the environment.rb's config.gem statements that define which gems you're going to use.

Hope this helps someone, who like me, is often confounded by terse answers that presume one is already expert enough that the question wouldn't have been asked in the first place...


If you look at environment.rb, it should have an entry like this

Rails::Initializer.run do |config|

end

it's inside that initializer that you place gem config statements. For instance, let's say you wanted to add the clearance gem and you needed v0.5.3 and the gem was located at gems.github.com...and you also wanted mislav-will paginate, the syntax might look a bit like this:

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

without those statements, rake:gems install won't load local copies of those gems to your application's vendor/gems folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM