{"id":732,"date":"2022-08-30T15:06:15","date_gmt":"2022-08-30T15:06:15","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/undefined-method-sub-while-running-rake-assetsprecompile-on-windows-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:06:15","modified_gmt":"2022-08-30T15:06:15","slug":"undefined-method-sub-while-running-rake-assetsprecompile-on-windows-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/undefined-method-sub-while-running-rake-assetsprecompile-on-windows-collection-of-common-programming-errors\/","title":{"rendered":"Undefined method `sub&#39; while running rake assets:precompile on Windows-Collection of common programming errors"},"content":{"rendered":"<p>When I attempt to run rake assets:precompile I am having a weird issue that appears to be related to my database.yml. However, accessing the website directly works fine (if i change the environment to fall back on the asset pipeline).<\/p>\n<p>Rails 3.2.12, ruby 1.9.3p385, Windows Server 2008.<\/p>\n<p>My database.yml file (host, username, and password removed):<\/p>\n<pre>\nproduction:\n  adapter: mysql2\n  encoding: utf8\n  reconnect: true\n  database: images\n  pool: 5\n  username: username\n  password: password\n  host: host\n<\/pre>\n<p>A snippet of the top portion of the error:<\/p>\n<pre>\nD:\\inetpub\\wwwroot\\images&gt;rake assets:precompile\nC:\/Ruby19\/bin\/ruby.exe C:\/Ruby19\/bin\/rake assets:precompile:all RAILS_ENV=assets:precompile RAILS_GROUPS=assets\nrake aborted!\nundefined method `sub' for nil:NilClass\nD:\/inetpub\/wwwroot\/images\/vendor\/bundle\/ruby\/1.9.1\/gems\/activerecord-3.2.12\/lib\/active_record\/connection_adapters\/abstract\/connection_specification.rb:68:in `co\nnnection_url_to_hash'\nD:\/inetpub\/wwwroot\/images\/vendor\/bundle\/ruby\/1.9.1\/gems\/activerecord-3.2.12\/lib\/active_record\/connection_adapters\/abstract\/connection_specification.rb:36:in `bl\nock in resolve_string_connection'\nD:\/inetpub\/wwwroot\/images\/vendor\/bundle\/ruby\/1.9.1\/gems\/activerecord-3.2.12\/lib\/active_record\/connection_adapters\/abstract\/connection_specification.rb:35:in `fe\ntch'\n<\/pre>\n<p><strong>Edit:<\/strong><\/p>\n<p>Here is the contents of connection_specification.rb, it bombs out on this line: <code>:database =&gt; config.path.sub(%r{^\/},\"\"),<\/code>:<\/p>\n<pre>\n       def connection_url_to_hash(url) # :nodoc:\n          config = URI.parse url\n          adapter = config.scheme\n          adapter = \"postgresql\" if adapter == \"postgres\"\n          spec = { :adapter  =&gt; adapter,\n                   :username =&gt; config.user,\n                   :password =&gt; config.password,\n                   :port     =&gt; config.port,\n                   :database =&gt; config.path.sub(%r{^\/},\"\"),\n                   :host     =&gt; config.host }\n          spec.reject!{ |_,value| value.blank? }\n          spec.map { |key,value| spec[key] = URI.unescape(value) if value.is_a?(String) }\n          if config.query\n            options = Hash[config.query.split(\"&amp;\").map{ |pair| pair.split(\"=\") }].symbolize_keys\n            spec.merge!(options)\n          end\n          spec\n        end\n      end\n    end\n<\/pre>\n<ol>\n<li>\n<p>Your output generates this: RAILS_ENV=assets:precompile<\/p>\n<p>however I do not think you&#8217;ve declared an assets environment.<\/p>\n<p>try <code>$:. rake assets:precompile RAILS_ENV='production' RAILS_GROUPS='assets'<\/code><\/p>\n<p>PS: windows is.. let&#8217;s say undeveloped when it comes to rails support so you may want to think about switching to another OS. My personal favorite is Debian sqeeze<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 21:44:33. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>When I attempt to run rake assets:precompile I am having a weird issue that appears to be related to my database.yml. However, accessing the website directly works fine (if i change the environment to fall back on the asset pipeline). Rails 3.2.12, ruby 1.9.3p385, Windows Server 2008. My database.yml file (host, username, and password removed): [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-732","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/732","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=732"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/732\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}