People, I have a small mystery which has me curious. mystery setup: from a shell type... rails mystery then cd mystery then type a line from p 57 of the rails book (p 62 of the pdf): script/generate scaffold Product Admin I see this: $ script/generate scaffold Product Admin dependency model exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/product.rb create test/unit/product_test.rb create test/fixtures/products.yml exists app/controllers/ exists app/helpers/ create app/views/admin exists test/functional/ create app/controllers/admin_controller.rb create test/functional/admin_controller_test.rb create app/helpers/admin_helper.rb create app/views/layouts/admin.rhtml create public/stylesheets/scaffold.css create app/views/admin/list.rhtml create app/views/admin/show.rhtml create app/views/admin/new.rhtml create app/views/admin/edit.rhtml No such file or directory - /tmp/mysql.sock $ I like to press my luck so I try the command again. It just hangs. So, I kill it Then, to gather clues, I run it via ruby -v: $ ruby -v script/generate scaffold Product Admin /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/class_inheritable_attributes.rb:116: warning: discarding old inherited /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:6: warning: method redefined; discarding old pluralize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:17: warning: method redefined; discarding old singularize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:28: warning: method redefined; discarding old camelize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:32: warning: method redefined; discarding old underscore /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:36: warning: method redefined; discarding old humanize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:40: warning: method redefined; discarding old demodulize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:44: warning: method redefined; discarding old tableize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:48: warning: method redefined; discarding old classify /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:52: warning: method redefined; discarding old foreign_key /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:57: warning: method redefined; discarding old constantize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:63: warning: method redefined; discarding old ordinalize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:77: warning: method redefined; discarding old uncountable_words /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:81: warning: method redefined; discarding old plural_rules /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:106: warning: method redefined; discarding old singular_rules /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:6: warning: method redefined; discarding old pluralize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:17: warning: method redefined; discarding old singularize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:28: warning: method redefined; discarding old camelize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:32: warning: method redefined; discarding old underscore /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:36: warning: method redefined; discarding old humanize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:40: warning: method redefined; discarding old demodulize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:44: warning: method redefined; discarding old tableize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:48: warning: method redefined; discarding old classify /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:52: warning: method redefined; discarding old foreign_key /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:57: warning: method redefined; discarding old constantize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:63: warning: method redefined; discarding old ordinalize /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:77: warning: method redefined; discarding old uncountable_words /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:81: warning: method redefined; discarding old plural_rules /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:106: warning: method redefined; discarding old singular_rules /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/clean_logger.rb:15: warning: method redefined; discarding old format_message /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/dependencies.rb:177: warning: method redefined; discarding old const_missing /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1.1962/lib/active_record/validations.rb:313: warning: `*'' interpreted as argument prefix /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1.1962/lib/active_record/validations.rb:342: warning: `*'' interpreted as argument prefix /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1.1962/lib/active_record/connection_adapters/oci_adapter.rb:58: warning: (...) interpreted as grouped expression /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1.1962/lib/active_record/query_cache.rb:47: warning: redefine connection/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/request.rb:168: warning: method redefined; discarding old relative_url_root /usr/local/lib/ruby/1.8/cgi/session/pstore.rb:17: warning: method redefined; discarding old []/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/cgi_ext/raw_post_data_fix.rb:8: warning: method redefined; discarding old initialize_query /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/session/active_record_store.rb:128: warning: redefine connection /usr/local/lib/ruby/gems/1.8/gems/actionmailer-1.0.1.1962/lib/action_mailer/vendor/tmail/facade.rb:467: warning: method redefined; discarding old create_reply /usr/local/lib/ruby/1.8/net/https.rb:121: warning: method redefined; discarding old edit_path /usr/local/lib/ruby/1.8/net/https.rb:130: warning: redefine socket_type /usr/local/lib/ruby/1.8/net/https.rb:157: warning: method redefined; discarding old on_connect /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/routing.rb:90: warning: instance variable @optional not initialized /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/routing.rb:90: warning: instance variable @optional not initialized /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/routing.rb:90: warning: instance variable @optional not initialized /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/routing.rb:90: warning: instance variable @optional not initialized /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:6: warning: redefine append_features /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:23: warning: method redefined; discarding old mandatory_options /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:31: warning: method redefined; discarding old default_options /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:43: warning: method redefined; discarding old full_options /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:50: warning: method redefined; discarding old options /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:57: warning: method redefined; discarding old mandatory_options /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:62: warning: method redefined; discarding old default_options /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:71: warning: method redefined; discarding old full_options /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:82: warning: method redefined; discarding old parse! /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:99: warning: method redefined; discarding old usage /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:103: warning: method redefined; discarding old usage_message /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:108: warning: method redefined; discarding old banner /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:116: warning: method redefined; discarding old add_options! /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:120: warning: method redefined; discarding old add_general_options! /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/spec.rb:16: warning: instance variable @klass not initialized /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:17: warning: method redefined; discarding old to_input_field_tag /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:22: warning: method redefined; discarding old to_text_area_tag /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:26: warning: method redefined; discarding old to_date_select_tag /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:30: warning: method redefined; discarding old to_datetime_select_tag /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/spec.rb:16: warning: instance variable @klass not initialized The last line tells me it is stuck on line 17 of /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/spec.rb I looked at the file... $ cat /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/spec.rb module Rails module Generator # A spec knows where a generator was found and how to instantiate it. # Metadata include the generator''s name, its base path, and the source # which yielded it (PathSource, GemSource, etc.) class Spec attr_reader :name, :path, :source def initialize(name, path, source) @name, @path, @source = name, path, source end # Look up the generator class. Require its class file, find the class # in ObjectSpace, tag it with this spec, and return. def klass unless @klass require class_file ## HERE IS LINE 17 @klass = lookup_class @klass.spec = self end @klass end def class_file "#{path}/#{name}_generator.rb" end def class_name "#{name.camelize}Generator" end private # Search for the first Class descending from Rails::Generator::Base # whose name matches the requested class name. def lookup_class ObjectSpace.each_object(Class) do |obj| return obj if obj.ancestors.include?(Rails::Generator::Base) and obj.name.split(''::'').last == class_name end raise NameError, "Missing #{class_name} class in #{class_file}" end end end end At this point I''m lost; I''m not sure why the command is "stuck". I''d expect it to issue an exception telling me that the class I''m trying to create already exists. What can I do to get script/generate to behave better? -Dan
Dan Bikle
2005-Sep-05 08:26 UTC
Re: I run generate twice; I get problem; How I work around?
People, I tried for cmd line help: $ script/generate Usage: script/generate [options] generator [args] General Options: -p, --pretend Run but do not make any changes. -f, --force Overwrite files that already exist. -s, --skip Skip files that already exist. -q, --quiet Suppress normal output. -t, --backtrace Debugging: show backtrace on errors. -h, --help Show this help message. Installed Generators Builtin: controller, mailer, migration, model, scaffold, web_service More are available at http://rubyonrails.org/show/Generators 1. Download, for example, login_generator.zip 2. Unzip to directory /Users/oracle/.rails/generators/login to use the generator with all your Rails apps or to /Users/oracle/pt/TThier/Languages/ruby/depot10/script/generators/login to use with this app only. 3. Run generate with no arguments for usage information script/generate login Generator gems are also available: 1. gem list generator -s http://gems.rubyonrails.org 2. gem install login_generator -s http://gems.rubyonrails.org 3. script/generate login The -f option looks good. I tried it: $ script/generate -f scaffold Product Admin Couldn''t find ''-f'' generator $ script/generate --force scaffold Product Admin Couldn''t find ''--force'' generator Darn, cmd line options do not work. Anyone have any tips on getting generate -f to work? -Dan On 9/4/05, Dan Bikle <dan.bikle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> People, > > I have a small mystery which has me curious. > > mystery setup: > > from a shell type... > > rails mystery > then > cd mystery > then type a line from p 57 of the rails book (p 62 of the pdf): > > script/generate scaffold Product Admin > > I see this: > > $ script/generate scaffold Product Admin > dependency model > exists app/models/ > exists test/unit/ > exists test/fixtures/ > create app/models/product.rb > create test/unit/product_test.rb > create test/fixtures/products.yml > exists app/controllers/ > exists app/helpers/ > create app/views/admin > exists test/functional/ > create app/controllers/admin_controller.rb > create test/functional/admin_controller_test.rb > create app/helpers/admin_helper.rb > create app/views/layouts/admin.rhtml > create public/stylesheets/scaffold.css > create app/views/admin/list.rhtml > create app/views/admin/show.rhtml > create app/views/admin/new.rhtml > create app/views/admin/edit.rhtml > No such file or directory - /tmp/mysql.sock > $ > > I like to press my luck so > I try the command again. > > It just hangs. > So, I kill it > > Then, to gather clues, I run it via ruby -v: > > $ ruby -v script/generate scaffold Product Admin > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/class_inheritable_attributes.rb:116: > warning: discarding old inherited > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:6: > warning: method redefined; discarding old pluralize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:17: > warning: method redefined; discarding old singularize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:28: > warning: method redefined; discarding old camelize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:32: > warning: method redefined; discarding old underscore > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:36: > warning: method redefined; discarding old humanize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:40: > warning: method redefined; discarding old demodulize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:44: > warning: method redefined; discarding old tableize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:48: > warning: method redefined; discarding old classify > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:52: > warning: method redefined; discarding old foreign_key > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:57: > warning: method redefined; discarding old constantize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:63: > warning: method redefined; discarding old ordinalize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:77: > warning: method redefined; discarding old uncountable_words > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:81: > warning: method redefined; discarding old plural_rules > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:106: > warning: method redefined; discarding old singular_rules > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:6: > warning: method redefined; discarding old pluralize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:17: > warning: method redefined; discarding old singularize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:28: > warning: method redefined; discarding old camelize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:32: > warning: method redefined; discarding old underscore > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:36: > warning: method redefined; discarding old humanize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:40: > warning: method redefined; discarding old demodulize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:44: > warning: method redefined; discarding old tableize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:48: > warning: method redefined; discarding old classify > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:52: > warning: method redefined; discarding old foreign_key > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:57: > warning: method redefined; discarding old constantize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:63: > warning: method redefined; discarding old ordinalize > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:77: > warning: method redefined; discarding old uncountable_words > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:81: > warning: method redefined; discarding old plural_rules > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:106: > warning: method redefined; discarding old singular_rules > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/clean_logger.rb:15: > warning: method redefined; discarding old format_message > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/dependencies.rb:177: > warning: method redefined; discarding old const_missing > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1.1962/lib/active_record/validations.rb:313: > warning: `*'' interpreted as argument prefix > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1.1962/lib/active_record/validations.rb:342: > warning: `*'' interpreted as argument prefix > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1.1962/lib/active_record/connection_adapters/oci_adapter.rb:58: > warning: (...) interpreted as grouped expression > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1.1962/lib/active_record/query_cache.rb:47: > warning: redefine connection> /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/request.rb:168: > warning: method redefined; discarding old relative_url_root > /usr/local/lib/ruby/1.8/cgi/session/pstore.rb:17: warning: method > redefined; discarding old []> /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/cgi_ext/raw_post_data_fix.rb:8: > warning: method redefined; discarding old initialize_query > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/session/active_record_store.rb:128: > warning: redefine connection > /usr/local/lib/ruby/gems/1.8/gems/actionmailer-1.0.1.1962/lib/action_mailer/vendor/tmail/facade.rb:467: > warning: method redefined; discarding old create_reply > /usr/local/lib/ruby/1.8/net/https.rb:121: warning: method redefined; > discarding old edit_path > /usr/local/lib/ruby/1.8/net/https.rb:130: warning: redefine socket_type > /usr/local/lib/ruby/1.8/net/https.rb:157: warning: method redefined; > discarding old on_connect > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/routing.rb:90: > warning: instance variable @optional not initialized > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/routing.rb:90: > warning: instance variable @optional not initialized > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/routing.rb:90: > warning: instance variable @optional not initialized > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/routing.rb:90: > warning: instance variable @optional not initialized > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:6: > warning: redefine append_features > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:23: > warning: method redefined; discarding old mandatory_options > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:31: > warning: method redefined; discarding old default_options > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:43: > warning: method redefined; discarding old full_options > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:50: > warning: method redefined; discarding old options > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:57: > warning: method redefined; discarding old mandatory_options > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:62: > warning: method redefined; discarding old default_options > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:71: > warning: method redefined; discarding old full_options > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:82: > warning: method redefined; discarding old parse! > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:99: > warning: method redefined; discarding old usage > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:103: > warning: method redefined; discarding old usage_message > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:108: > warning: method redefined; discarding old banner > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:116: > warning: method redefined; discarding old add_options! > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:120: > warning: method redefined; discarding old add_general_options! > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/spec.rb:16: > warning: instance variable @klass not initialized > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:17: > warning: method redefined; discarding old to_input_field_tag > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:22: > warning: method redefined; discarding old to_text_area_tag > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:26: > warning: method redefined; discarding old to_date_select_tag > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:30: > warning: method redefined; discarding old to_datetime_select_tag > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/spec.rb:16: > warning: instance variable @klass not initialized > > The last line tells me it is stuck on line 17 of > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/spec.rb > > I looked at the file... > > $ cat /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/spec.rb > module Rails > module Generator > # A spec knows where a generator was found and how to instantiate it. > # Metadata include the generator''s name, its base path, and the source > # which yielded it (PathSource, GemSource, etc.) > class Spec > attr_reader :name, :path, :source > > def initialize(name, path, source) > @name, @path, @source = name, path, source > end > > # Look up the generator class. Require its class file, find the class > # in ObjectSpace, tag it with this spec, and return. > def klass > unless @klass > require class_file ## HERE IS LINE 17 > @klass = lookup_class > @klass.spec = self > end > @klass > end > > def class_file > "#{path}/#{name}_generator.rb" > end > > def class_name > "#{name.camelize}Generator" > end > > private > # Search for the first Class descending from Rails::Generator::Base > # whose name matches the requested class name. > def lookup_class > ObjectSpace.each_object(Class) do |obj| > return obj if obj.ancestors.include?(Rails::Generator::Base) and > obj.name.split(''::'').last == class_name > end > raise NameError, "Missing #{class_name} class in #{class_file}" > end > end > end > end > > At this point I''m lost; I''m not sure why the command is "stuck". > > I''d expect it to issue an exception telling me that the class I''m > trying to create already exists. > > What can I do to get > script/generate > to behave better? > > -Dan >
Dan Bikle
2005-Sep-05 09:00 UTC
Re: I run generate twice; I get problem; How I work around?
People, I ran some more experiments and found that generate works best if I run it from a proper terminal window. Over the years, I developed a habit of commands in an emacs shell. When I run generate in an emacs shell, it has trouble prompting me when it wants to overwrite a file. To me, generate appears hung but really it is just waiting for me to type something at the keyboard: y, n, a... -Dan On 9/5/05, Dan Bikle <dan.bikle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> People, > > I tried for cmd line help: > > $ script/generate > Usage: script/generate [options] generator [args] > > General Options: > -p, --pretend Run but do not make any changes. > -f, --force Overwrite files that already exist. > -s, --skip Skip files that already exist. > -q, --quiet Suppress normal output. > -t, --backtrace Debugging: show backtrace on errors. > -h, --help Show this help message. > > > Installed Generators > Builtin: controller, mailer, migration, model, scaffold, web_service > > More are available at http://rubyonrails.org/show/Generators > 1. Download, for example, login_generator.zip > 2. Unzip to directory /Users/oracle/.rails/generators/login > to use the generator with all your Rails apps > or to /Users/oracle/pt/TThier/Languages/ruby/depot10/script/generators/login > to use with this app only. > 3. Run generate with no arguments for usage information > script/generate login > > Generator gems are also available: > 1. gem list generator -s http://gems.rubyonrails.org > 2. gem install login_generator -s http://gems.rubyonrails.org > 3. script/generate login > > The > -f > option looks good. > > I tried it: > > $ script/generate -f scaffold Product Admin > Couldn''t find ''-f'' generator > > $ script/generate --force scaffold Product Admin > Couldn''t find ''--force'' generator > > Darn, cmd line options do not work. > > Anyone have any tips on getting > generate -f > to work? > > -Dan > > > On 9/4/05, Dan Bikle <dan.bikle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > People, > > > > I have a small mystery which has me curious. > > > > mystery setup: > > > > from a shell type... > > > > rails mystery > > then > > cd mystery > > then type a line from p 57 of the rails book (p 62 of the pdf): > > > > script/generate scaffold Product Admin > > > > I see this: > > > > $ script/generate scaffold Product Admin > > dependency model > > exists app/models/ > > exists test/unit/ > > exists test/fixtures/ > > create app/models/product.rb > > create test/unit/product_test.rb > > create test/fixtures/products.yml > > exists app/controllers/ > > exists app/helpers/ > > create app/views/admin > > exists test/functional/ > > create app/controllers/admin_controller.rb > > create test/functional/admin_controller_test.rb > > create app/helpers/admin_helper.rb > > create app/views/layouts/admin.rhtml > > create public/stylesheets/scaffold.css > > create app/views/admin/list.rhtml > > create app/views/admin/show.rhtml > > create app/views/admin/new.rhtml > > create app/views/admin/edit.rhtml > > No such file or directory - /tmp/mysql.sock > > $ > > > > I like to press my luck so > > I try the command again. > > > > It just hangs. > > So, I kill it > > > > Then, to gather clues, I run it via ruby -v: > > > > $ ruby -v script/generate scaffold Product Admin > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/class_inheritable_attributes.rb:116: > > warning: discarding old inherited > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:6: > > warning: method redefined; discarding old pluralize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:17: > > warning: method redefined; discarding old singularize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:28: > > warning: method redefined; discarding old camelize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:32: > > warning: method redefined; discarding old underscore > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:36: > > warning: method redefined; discarding old humanize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:40: > > warning: method redefined; discarding old demodulize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:44: > > warning: method redefined; discarding old tableize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:48: > > warning: method redefined; discarding old classify > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:52: > > warning: method redefined; discarding old foreign_key > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:57: > > warning: method redefined; discarding old constantize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:63: > > warning: method redefined; discarding old ordinalize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:77: > > warning: method redefined; discarding old uncountable_words > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:81: > > warning: method redefined; discarding old plural_rules > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/integer/../../inflector.rb:106: > > warning: method redefined; discarding old singular_rules > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:6: > > warning: method redefined; discarding old pluralize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:17: > > warning: method redefined; discarding old singularize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:28: > > warning: method redefined; discarding old camelize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:32: > > warning: method redefined; discarding old underscore > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:36: > > warning: method redefined; discarding old humanize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:40: > > warning: method redefined; discarding old demodulize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:44: > > warning: method redefined; discarding old tableize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:48: > > warning: method redefined; discarding old classify > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:52: > > warning: method redefined; discarding old foreign_key > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:57: > > warning: method redefined; discarding old constantize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:63: > > warning: method redefined; discarding old ordinalize > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:77: > > warning: method redefined; discarding old uncountable_words > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:81: > > warning: method redefined; discarding old plural_rules > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/core_ext/string/../../inflector.rb:106: > > warning: method redefined; discarding old singular_rules > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/clean_logger.rb:15: > > warning: method redefined; discarding old format_message > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1.1962/lib/active_support/dependencies.rb:177: > > warning: method redefined; discarding old const_missing > > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1.1962/lib/active_record/validations.rb:313: > > warning: `*'' interpreted as argument prefix > > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1.1962/lib/active_record/validations.rb:342: > > warning: `*'' interpreted as argument prefix > > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1.1962/lib/active_record/connection_adapters/oci_adapter.rb:58: > > warning: (...) interpreted as grouped expression > > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1.1962/lib/active_record/query_cache.rb:47: > > warning: redefine connection> > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/request.rb:168: > > warning: method redefined; discarding old relative_url_root > > /usr/local/lib/ruby/1.8/cgi/session/pstore.rb:17: warning: method > > redefined; discarding old []> > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/cgi_ext/raw_post_data_fix.rb:8: > > warning: method redefined; discarding old initialize_query > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/session/active_record_store.rb:128: > > warning: redefine connection > > /usr/local/lib/ruby/gems/1.8/gems/actionmailer-1.0.1.1962/lib/action_mailer/vendor/tmail/facade.rb:467: > > warning: method redefined; discarding old create_reply > > /usr/local/lib/ruby/1.8/net/https.rb:121: warning: method redefined; > > discarding old edit_path > > /usr/local/lib/ruby/1.8/net/https.rb:130: warning: redefine socket_type > > /usr/local/lib/ruby/1.8/net/https.rb:157: warning: method redefined; > > discarding old on_connect > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/routing.rb:90: > > warning: instance variable @optional not initialized > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/routing.rb:90: > > warning: instance variable @optional not initialized > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/routing.rb:90: > > warning: instance variable @optional not initialized > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.9.1.1962/lib/action_controller/routing.rb:90: > > warning: instance variable @optional not initialized > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:6: > > warning: redefine append_features > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:23: > > warning: method redefined; discarding old mandatory_options > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:31: > > warning: method redefined; discarding old default_options > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:43: > > warning: method redefined; discarding old full_options > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:50: > > warning: method redefined; discarding old options > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:57: > > warning: method redefined; discarding old mandatory_options > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:62: > > warning: method redefined; discarding old default_options > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:71: > > warning: method redefined; discarding old full_options > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:82: > > warning: method redefined; discarding old parse! > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:99: > > warning: method redefined; discarding old usage > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:103: > > warning: method redefined; discarding old usage_message > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:108: > > warning: method redefined; discarding old banner > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:116: > > warning: method redefined; discarding old add_options! > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/scripts/../options.rb:120: > > warning: method redefined; discarding old add_general_options! > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/spec.rb:16: > > warning: instance variable @klass not initialized > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:17: > > warning: method redefined; discarding old to_input_field_tag > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:22: > > warning: method redefined; discarding old to_text_area_tag > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:26: > > warning: method redefined; discarding old to_date_select_tag > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:30: > > warning: method redefined; discarding old to_datetime_select_tag > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/spec.rb:16: > > warning: instance variable @klass not initialized > > > > The last line tells me it is stuck on line 17 of > > /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/spec.rb > > > > I looked at the file... > > > > $ cat /usr/local/lib/ruby/gems/1.8/gems/rails-0.13.1.1962/lib/rails_generator/spec.rb > > module Rails > > module Generator > > # A spec knows where a generator was found and how to instantiate it. > > # Metadata include the generator''s name, its base path, and the source > > # which yielded it (PathSource, GemSource, etc.) > > class Spec > > attr_reader :name, :path, :source > > > > def initialize(name, path, source) > > @name, @path, @source = name, path, source > > end > > > > # Look up the generator class. Require its class file, find the class > > # in ObjectSpace, tag it with this spec, and return. > > def klass > > unless @klass > > require class_file ## HERE IS LINE 17 > > @klass = lookup_class > > @klass.spec = self > > end > > @klass > > end > > > > def class_file > > "#{path}/#{name}_generator.rb" > > end > > > > def class_name > > "#{name.camelize}Generator" > > end > > > > private > > # Search for the first Class descending from Rails::Generator::Base > > # whose name matches the requested class name. > > def lookup_class > > ObjectSpace.each_object(Class) do |obj| > > return obj if obj.ancestors.include?(Rails::Generator::Base) and > > obj.name.split(''::'').last == class_name > > end > > raise NameError, "Missing #{class_name} class in #{class_file}" > > end > > end > > end > > end > > > > At this point I''m lost; I''m not sure why the command is "stuck". > > > > I''d expect it to issue an exception telling me that the class I''m > > trying to create already exists. > > > > What can I do to get > > script/generate > > to behave better? > > > > -Dan > > >
Dave Silvester
2005-Sep-05 13:59 UTC
Re: I run generate twice; I get problem; How I work around?
Dan Bikle wrote:> No such file or directory - /tmp/mysql.sockAs far as I can tell, that right there is your problem. I would guess it can''t find the database to connect to in order to generate the scaffold. What platform are you on? I''m guessing Linux, but this should work on OSX or any other *nix variant. So, is MySQL actually running? What do you have in your mysql config file (which on this Gentoo box is located in /etc/mysql/myy.cnf)? In mine, there is a line that says: socket = /var/run/mysqld/mysqld.sock Perhaps the quickest method (since I''m not exactly sure where this error happens) would be for you to just create a symlink from wherever it''s expecting to find the file. So something like this might do the trick (obviously adjust for the path from your my.cnf file): ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock This may be a wild goose chase, sorry if I''ve led you off down the wrong path! Cheers, ~Dave -- Dave Silvester Rent-A-Monkey Website Development Web: http://www.rentamonkey.com/
Ronny Hanssen
2005-Sep-05 16:23 UTC
Re: I run generate twice; I get problem; How I work around?
As I said earlier, and as proposed by Dave. I too think that your problem has nothing to do with the generator. It can't find the database. Do you have a database up and running? If not - get it up'n'running. Be aware of MySQL's issues in terms of passwords and the ruby mysql libraries. Ronny On 9/5/05, Dave Silvester <dave@rentamonkey.com> wrote:> > Dan Bikle wrote: > > No such file or directory - /tmp/mysql.sock > > As far as I can tell, that right there is your problem. I would guess it > can't find the database to connect to in order to generate the scaffold. > > What platform are you on? I'm guessing Linux, but this should work on OSX > or > any other *nix variant. > > So, is MySQL actually running? What do you have in your mysql config file > (which on this Gentoo box is located in /etc/mysql/myy.cnf)? > > In mine, there is a line that says: > > socket = /var/run/mysqld/mysqld.sock > > Perhaps the quickest method (since I'm not exactly sure where this error > happens) would be for you to just create a symlink from wherever it's > expecting to find the file. > > So something like this might do the trick (obviously adjust for the path > from > your my.cnf file): > > ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock > > This may be a wild goose chase, sorry if I've led you off down the wrong > path! > > Cheers, > > ~Dave > > -- > > Dave Silvester > Rent-A-Monkey Website Development > Web: http://www.rentamonkey.com/ > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Dan Bikle
2005-Sep-05 17:02 UTC
Re: I run generate twice; I get problem; How I work around?
Dave, Ronny, My current environment: Mac OS X 10.3.9 Rails rails-0.13.1.1962 no database (in this demo) Rails will do what it can if the database is gone. My problem (or I should say Rails problem with me) was that I was running my Rails shell commands from within an emacs shell. My problems evaporated once I ran the script/generate command from a proper terminal window: $ cd /tmp biklemac:/tmp $ rails mystery create create app/apis create app/controllers create app/helpers create app/models create app/views/layouts create config/environments create components create db create doc create lib create log create public/images create public/javascripts create public/stylesheets create script create script/process create test/fixtures create test/functional create test/mocks/development create test/mocks/test create test/unit create vendor create Rakefile create README create CHANGELOG create app/controllers/application.rb create app/helpers/application_helper.rb create test/test_helper.rb create config/database.yml create config/routes.rb create public/.htaccess create config/environment.rb create config/environments/production.rb create config/environments/development.rb create config/environments/test.rb create script/console create script/destroy create script/generate create script/server create script/runner create script/benchmarker create script/profiler create script/process/reaper create script/process/spinner create script/process/spawner create script/breakpointer create public/dispatch.rb create public/dispatch.cgi create public/dispatch.fcgi create public/404.html create public/500.html create public/index.html create public/favicon.ico create public/robots.txt create public/javascripts/prototype.js create public/javascripts/effects.js create public/javascripts/dragdrop.js create public/javascripts/controls.js create doc/README_FOR_APP create log/server.log create log/production.log create log/development.log create log/test.log biklemac:/tmp $ cd mystery biklemac:/tmp/mystery $ script/generate scaffold Amodel Acontroller dependency model exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/amodel.rb create test/unit/amodel_test.rb create test/fixtures/amodels.yml exists app/controllers/ exists app/helpers/ create app/views/acontroller exists test/functional/ create app/controllers/acontroller_controller.rb create test/functional/acontroller_controller_test.rb create app/helpers/acontroller_helper.rb create app/views/layouts/acontroller.rhtml create public/stylesheets/scaffold.css create app/views/acontroller/list.rhtml create app/views/acontroller/show.rhtml create app/views/acontroller/new.rhtml create app/views/acontroller/edit.rhtml No such file or directory - /tmp/mysql.sock I''m in a proper terminal here; not emacs shell. The command below will ''hang'' in an emacs shell but works fine in a terminal window: biklemac:/tmp/mystery $ !! script/generate scaffold Amodel Acontroller dependency model exists app/models/ exists test/unit/ exists test/fixtures/ skip app/models/amodel.rb skip test/unit/amodel_test.rb skip test/fixtures/amodels.yml exists app/controllers/ exists app/helpers/ exists app/views/acontroller exists test/functional/ overwrite app/controllers/acontroller_controller.rb? [Ynaq] q aborting scaffold biklemac:/tmp/mystery $ -Dan On 9/5/05, Ronny Hanssen <super.ronny-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> As I said earlier, and as proposed by Dave. I too think that your problem > has nothing to do with the generator. It can''t find the database. > > Do you have a database up and running? > > If not - get it up''n''running. Be aware of MySQL''s issues in terms of > passwords and the ruby mysql libraries. > > Ronny > > > On 9/5/05, Dave Silvester <dave-AJqNGCqIqVQ7cdpDWioORw@public.gmane.org> wrote: > > Dan Bikle wrote: > > > No such file or directory - /tmp/mysql.sock > > > > As far as I can tell, that right there is your problem. I would guess it > > can''t find the database to connect to in order to generate the scaffold. > > > > What platform are you on? I''m guessing Linux, but this should work on OSX > or > > any other *nix variant. > > > > So, is MySQL actually running? What do you have in your mysql config file > > (which on this Gentoo box is located in /etc/mysql/myy.cnf)? > > > > In mine, there is a line that says: > > > > socket = /var/run/mysqld/mysqld.sock > > > > Perhaps the quickest method (since I''m not exactly sure where this error > > happens) would be for you to just create a symlink from wherever it''s > > expecting to find the file. > > > > So something like this might do the trick (obviously adjust for the path > from > > your my.cnf file): > > > > ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock > > > > This may be a wild goose chase, sorry if I''ve led you off down the wrong > path! > > > > Cheers, > > > > ~Dave > > > > -- > > > > Dave Silvester > > Rent-A-Monkey Website Development > > Web: http://www.rentamonkey.com/ > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >