fractaledmind / enlitenment

A Rails application template script to lead your app to SQLite enlightenment.
44 stars 3 forks source link

Execution is not idempotent #3

Closed thedumbtechguy closed 2 months ago

thedumbtechguy commented 2 months ago

Describe the bug Running the application multiple times results in multiple instances of duplicated config.

Additionally, there are duplicate route errors reported but they do not halt the execution of the script.

To Reproduce

Simply apply the template twice.

Expected behavior

There should be no change

Additional context

Diff ```diff diff --git a/Gemfile b/Gemfile index 5ee9f9c..cc3d217 100644 --- a/Gemfile +++ b/Gemfile @@ -66,3 +66,13 @@ gem "mission_control-jobs", "~> 0.3" gem "solid_cache", github: "rails/solid_cache", branch: "main" # Ensure all SQLite databases are backed up gem "litestream", "~> 0.10.0" +# Ensure all SQLite connections are properly configured +gem "activerecord-enhancedsqlite3-adapter", "~> 0.8.0" +# Add Solid Queue for background jobs +gem "solid_queue", github: "rails/solid_queue", branch: "main" +# Add a web UI for Solid Queue +gem "mission_control-jobs", "~> 0.3" +# Add Solid Cache as an Active Support cache store +gem "solid_cache", github: "rails/solid_cache", branch: "main" +# Ensure all SQLite databases are backed up +gem "litestream", "~> 0.10.0" diff --git a/config/application.rb b/config/application.rb index 62e4f8e..85e291a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -31,6 +31,14 @@ module TallMast # Ensure authorization is enabled for the Solid Queue web UI config.mission_control.jobs.base_controller_class = "ApplicationController" + # Use Solid Queue for background jobs + config.active_job.queue_adapter = :solid_queue + config.solid_queue.connects_to = { database: { writing: :queue } } + # Ensure authorization is enabled for the Solid Queue web UI + config.mission_control.jobs.base_controller_class = "ApplicationController" + # Ensure authorization is enabled for the Solid Queue web UI + config.mission_control.jobs.base_controller_class = "ApplicationController" + # Please, add to the `ignore` list any other `lib` subdirectories that do # not contain `.rb` files, or that should not be reloaded or eager loaded. # Common ones are `templates`, `generators`, or `middleware`, for example. diff --git a/config/database.yml b/config/database.yml index 3795dd7..09f5c31 100644 --- a/config/database.yml +++ b/config/database.yml @@ -25,6 +25,8 @@ development: database: storage/development.sqlite3 queue: *queue cache: *cache + queue: *queue + cache: *cache # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". @@ -35,6 +37,8 @@ test: database: storage/test.sqlite3 queue: *queue cache: *cache + queue: *queue + cache: *cache # SQLite3 write its data on the local filesystem, as such it requires @@ -49,3 +53,5 @@ production: # database: path/to/persistent/storage/production.sqlite3 queue: *queue cache: *cache + queue: *queue + cache: *cache diff --git a/config/routes.rb b/config/routes.rb index 9c33ef3..d77f4b0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,8 @@ Rails.application.routes.draw do mount MissionControl::Jobs::Engine, at: "/jobs" + mount MissionControl::Jobs::Engine, at: "/jobs" + # Render dynamic PWA files from app/views/pwa/* get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker get "manifest" => "rails/pwa#manifest", as: :pwa_manifest ```
Console Output ```console user@C02YV2TVLVCF tall_mast % bin/rails app:template \ LOCATION=/Users/user/Desktop/enlitenment-main/template.rb => [plutonium] starting reloader apply /Users/user/Desktop/enlitenment-main/template.rb gemfile activerecord-enhancedsqlite3-adapter (~> 0.8.0) gemfile solid_queue run bundle install from "." Your Gemfile lists the gem activerecord-enhancedsqlite3-adapter (~> 0.8.0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Your Gemfile lists the gem solid_queue (>= 0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Bundle complete! 27 Gemfile dependencies, 133 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. def_db queue (database.yml) add_db queue -> development (database.yml) add_db queue -> test (database.yml) add_db queue -> production (database.yml) run bin/rails generate solid_queue:install from "." => [plutonium] starting reloader gsub config/environments/production.rb identical config/solid_queue.yml rails railties:install:migrations FROM=solid_queue run bin/rails db:migrate:queue from "." => [plutonium] starting reloader insert config/application.rb unchanged config/puma.rb gemfile mission_control-jobs (~> 0.3) insert config/routes.rb insert config/application.rb gemfile solid_cache run bundle install from "." Your Gemfile lists the gem activerecord-enhancedsqlite3-adapter (~> 0.8.0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Your Gemfile lists the gem solid_queue (>= 0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Your Gemfile lists the gem mission_control-jobs (~> 0.3) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Your Gemfile lists the gem solid_cache (>= 0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Bundle complete! 29 Gemfile dependencies, 133 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. def_db cache (database.yml) add_db cache -> development (database.yml) add_db cache -> test (database.yml) add_db cache -> production (database.yml) run bin/rails generate solid_cache:install from "." => [plutonium] starting reloader /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/route_set.rb:637:in `add_route': Invalid route name, already in use: 'mission_control_jobs' (ArgumentError) You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here: https://guides.rubyonrails.org/routing.html#restricting-the-routes-created raise ArgumentError, "Invalid route name, already in use: '#{name}' \n" \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:2031:in `add_route' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:2002:in `decomposed_match' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:1966:in `block in map_match' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:1960:in `each' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:1960:in `map_match' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:1708:in `match' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:656:in `mount' from /Users/user/code/tall_mast/config/routes.rb:13:in `block in
' from /Users/user/code/plutonium/starters/vulcan/gems/plutonium/lib/plutonium/routing/route_set_extensions.rb:40:in `instance_exec' from /Users/user/code/plutonium/starters/vulcan/gems/plutonium/lib/plutonium/routing/route_set_extensions.rb:40:in `block (2 levels) in draw' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/route_set.rb:467:in `instance_exec' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/route_set.rb:467:in `eval_block' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/route_set.rb:449:in `draw' from /Users/user/code/plutonium/starters/vulcan/gems/plutonium/lib/plutonium/routing/route_set_extensions.rb:38:in `block in draw' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.2.0/lib/active_support/notifications.rb:210:in `block in instrument' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.2.0/lib/active_support/notifications/instrumenter.rb:58:in `instrument' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.2.0/lib/active_support/notifications.rb:210:in `instrument' from /Users/user/code/plutonium/starters/vulcan/gems/plutonium/lib/plutonium/routing/route_set_extensions.rb:37:in `draw' from /Users/user/code/tall_mast/config/routes.rb:1:in `
' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:50:in `load' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:50:in `block in load_paths' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:50:in `each' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:50:in `load_paths' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:24:in `reload!' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:38:in `block in updater' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.2.0/lib/active_support/file_update_checker.rb:85:in `execute' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:13:in `execute' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/finisher.rb:162:in `block in ' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/initializable.rb:32:in `instance_exec' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/initializable.rb:32:in `run' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/initializable.rb:61:in `block in run_initializers' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `call' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/initializable.rb:60:in `run_initializers' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application.rb:428:in `initialize!' from /Users/user/code/tall_mast/config/environment.rb:5:in `
' from :37:in `require' from :37:in `require' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.17/lib/zeitwerk/kernel.rb:34:in `require' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application.rb:404:in `require_environment!' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/command/actions.rb:20:in `boot_application!' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/commands/generate/generate_command.rb:21:in `perform' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/command/base.rb:178:in `invoke_command' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/command/base.rb:73:in `perform' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/command.rb:71:in `block in invoke' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/command.rb:149:in `with_argv' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/command.rb:69:in `invoke' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/commands.rb:18:in `
' from :37:in `require' from :37:in `require' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' from bin/rails:4:in `
' run bin/rails db:migrate:cache from "." => [plutonium] starting reloader bin/rails aborted! ArgumentError: Invalid route name, already in use: 'mission_control_jobs' (ArgumentError) You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here: https://guides.rubyonrails.org/routing.html#restricting-the-routes-created raise ArgumentError, "Invalid route name, already in use: '#{name}' \n" \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /Users/user/code/tall_mast/config/routes.rb:13:in `block in
' /Users/user/code/tall_mast/config/routes.rb:1:in `
' /Users/user/code/tall_mast/config/environment.rb:5:in `
' Tasks: TOP => db:migrate:cache => db:load_config => environment (See full trace by running task with --trace) gsub config/solid_cache.yml Enable caching in development? yes run bin/rails dev:cache from "." Development mode is now being cached. gemfile litestream (~> 0.10.0) run bundle install from "." Your Gemfile lists the gem activerecord-enhancedsqlite3-adapter (~> 0.8.0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Your Gemfile lists the gem solid_queue (>= 0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Your Gemfile lists the gem mission_control-jobs (~> 0.3) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Your Gemfile lists the gem solid_cache (>= 0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Your Gemfile lists the gem litestream (~> 0.10.0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Bundle complete! 30 Gemfile dependencies, 133 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. run bin/rails generate litestream:install from "." => [plutonium] starting reloader /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/route_set.rb:637:in `add_route': Invalid route name, already in use: 'mission_control_jobs' (ArgumentError) You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here: https://guides.rubyonrails.org/routing.html#restricting-the-routes-created raise ArgumentError, "Invalid route name, already in use: '#{name}' \n" \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:2031:in `add_route' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:2002:in `decomposed_match' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:1966:in `block in map_match' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:1960:in `each' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:1960:in `map_match' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:1708:in `match' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/mapper.rb:656:in `mount' from /Users/user/code/tall_mast/config/routes.rb:13:in `block in
' from /Users/user/code/plutonium/starters/vulcan/gems/plutonium/lib/plutonium/routing/route_set_extensions.rb:40:in `instance_exec' from /Users/user/code/plutonium/starters/vulcan/gems/plutonium/lib/plutonium/routing/route_set_extensions.rb:40:in `block (2 levels) in draw' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/route_set.rb:467:in `instance_exec' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/route_set.rb:467:in `eval_block' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.2.0/lib/action_dispatch/routing/route_set.rb:449:in `draw' from /Users/user/code/plutonium/starters/vulcan/gems/plutonium/lib/plutonium/routing/route_set_extensions.rb:38:in `block in draw' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.2.0/lib/active_support/notifications.rb:210:in `block in instrument' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.2.0/lib/active_support/notifications/instrumenter.rb:58:in `instrument' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.2.0/lib/active_support/notifications.rb:210:in `instrument' from /Users/user/code/plutonium/starters/vulcan/gems/plutonium/lib/plutonium/routing/route_set_extensions.rb:37:in `draw' from /Users/user/code/tall_mast/config/routes.rb:1:in `
' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:50:in `load' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:50:in `block in load_paths' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:50:in `each' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:50:in `load_paths' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:24:in `reload!' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:38:in `block in updater' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.2.0/lib/active_support/file_update_checker.rb:85:in `execute' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/routes_reloader.rb:13:in `execute' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application/finisher.rb:162:in `block in ' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/initializable.rb:32:in `instance_exec' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/initializable.rb:32:in `run' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/initializable.rb:61:in `block in run_initializers' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `call' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/initializable.rb:60:in `run_initializers' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application.rb:428:in `initialize!' from /Users/user/code/tall_mast/config/environment.rb:5:in `
' from :37:in `require' from :37:in `require' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.17/lib/zeitwerk/kernel.rb:34:in `require' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/application.rb:404:in `require_environment!' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/command/actions.rb:20:in `boot_application!' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/commands/generate/generate_command.rb:21:in `perform' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/command/base.rb:178:in `invoke_command' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/command/base.rb:73:in `perform' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/command.rb:71:in `block in invoke' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/command.rb:149:in `with_argv' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/command.rb:69:in `invoke' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.2.0/lib/rails/commands.rb:18:in `
' from :37:in `require' from :37:in `require' from /Users/user/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' from bin/rails:4:in `
' unchanged config/puma.rb In order to use Litestream, you need to have an S3-compatible storage provider. You can use AWS S3, DigitalOcean Spaces, or any other provider that is compatible with the S3 API. Once you have a bucket created, you will need to provide the credentials to Litestream for this Rails app. Do you want to configure Litestream with Rails' credentials? yes gsub config/initializers/litestream.rb Edit your application's credentials to store your bucket details with: bin/rails credentials:edit You can confirm that everything is configured correctly by running and inspecting the output of the following command: bin/rails litestream:env run bundle install --quiet Your Gemfile lists the gem activerecord-enhancedsqlite3-adapter (~> 0.8.0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Your Gemfile lists the gem solid_queue (>= 0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Your Gemfile lists the gem mission_control-jobs (~> 0.3) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Your Gemfile lists the gem solid_cache (>= 0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Your Gemfile lists the gem litestream (~> 0.10.0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. ```
fractaledmind commented 2 months ago

@thedumbtechguy: I just pushed a new version that should be idempotent. The test suite also has tests to ensure the template is idempotent. Please try again and let me know if things look good on your end.

thedumbtechguy commented 2 months ago

confirmed! works super well now.

thedumbtechguy commented 2 months ago

Noticed that migration errors are reported but don't halt the script. Is that intended?

fractaledmind commented 2 months ago

Noticed that migration errors are reported but don't halt the script. Is that intended?

Can you give me the output?

thedumbtechguy commented 2 months ago

Note: this bug is not related to your script. It's because I just rolled back all changes hence the migration failing.

The only reason I raise it is when migrations fail for some reason in the user's app, they might not notice.

Console log ```console user@C02YV2TVLVCF tall_mast % bin/rails app:template \ LOCATION=/Users/user/Desktop/enlitenment-main/template.rb => [plutonium] starting reloader apply /Users/user/Desktop/enlitenment-main/template.rb run bundle install from "." Bundle complete! 25 Gemfile dependencies, 133 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. def_db queue (database.yml) run bin/rails generate solid_queue:install from "." => [plutonium] starting reloader gsub config/environments/production.rb identical config/solid_queue.yml rails railties:install:migrations FROM=solid_queue run bin/rails db:migrate:queue from "." => [plutonium] starting reloader == 20240816091432 CreateSolidQueueTables: migrating =========================== -- create_table(:solid_queue_jobs) bin/rails aborted! StandardError: An error has occurred, this and all later migrations canceled: (StandardError) SQLite3::SQLException: table "solid_queue_jobs" already exists /Users/user/code/tall_mast/db/queue_migrate/20240816091432_create_solid_queue_tables.solid_queue.rb:4:in `change' Caused by: ActiveRecord::StatementInvalid: SQLite3::SQLException: table "solid_queue_jobs" already exists (ActiveRecord::StatementInvalid) /Users/user/code/tall_mast/db/queue_migrate/20240816091432_create_solid_queue_tables.solid_queue.rb:4:in `change' Caused by: SQLite3::SQLException: table "solid_queue_jobs" already exists (SQLite3::SQLException) /Users/user/code/tall_mast/db/queue_migrate/20240816091432_create_solid_queue_tables.solid_queue.rb:4:in `change' Tasks: TOP => db:migrate:queue (See full trace by running task with --trace) unchanged config/puma.rb run bundle install from "." Bundle complete! 25 Gemfile dependencies, 133 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. def_db cache (database.yml) run bin/rails generate solid_cache:install from "." => [plutonium] starting reloader gsub config/environments/development.rb gsub config/environments/test.rb gsub config/environments/production.rb conflict config/solid_cache.yml Overwrite /Users/user/code/tall_mast/config/solid_cache.yml? (enter "h" for help) [Ynaqdhm] ```
fractaledmind commented 2 months ago

Yeah, now that the script is idempotent, halting, reporting, and instructing the user to try again is indeed likely a better path. Just pushed a fix. Example expected output:

     gemfile    activerecord-enhancedsqlite3-adapter (~> 0.8.0)
     gemfile    solid_queue
      def_db    queue (database.yml)
      add_db    queue -> development (database.yml)
      add_db    queue -> test (database.yml)
      add_db    queue -> production (database.yml)
         run    bin/rails generate solid_queue:install from "."
       error    Failed to run `bin/rails generate solid_queue:install`. Resolve and try again
thedumbtechguy commented 2 months ago

Golden!

user@C02YV2TVLVCF tall_mast % bin/rails app:template \
  LOCATION=/Users/user/Desktop/enlitenment-main/template.rb
=> [plutonium] starting reloader
       apply  /Users/user/Desktop/enlitenment-main/template.rb
         run    bundle install from "."
Bundle complete! 25 Gemfile dependencies, 133 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
      def_db    queue (database.yml)
         run    bin/rails generate solid_queue:install from "."
=> [plutonium] starting reloader
        gsub  config/environments/production.rb
   identical  config/solid_queue.yml
       rails  railties:install:migrations FROM=solid_queue
         run    bin/rails db:migrate:queue from "."
=> [plutonium] starting reloader
== 20240816091432 CreateSolidQueueTables: migrating ===========================
-- create_table(:solid_queue_jobs)
bin/rails aborted!
StandardError: An error has occurred, this and all later migrations canceled: (StandardError)

SQLite3::SQLException: table "solid_queue_jobs" already exists
/Users/user/code/tall_mast/db/queue_migrate/20240816091432_create_solid_queue_tables.solid_queue.rb:4:in `change'

Caused by:
ActiveRecord::StatementInvalid: SQLite3::SQLException: table "solid_queue_jobs" already exists (ActiveRecord::StatementInvalid)
/Users/user/code/tall_mast/db/queue_migrate/20240816091432_create_solid_queue_tables.solid_queue.rb:4:in `change'

Caused by:
SQLite3::SQLException: table "solid_queue_jobs" already exists (SQLite3::SQLException)
/Users/user/code/tall_mast/db/queue_migrate/20240816091432_create_solid_queue_tables.solid_queue.rb:4:in `change'
Tasks: TOP => db:migrate:queue
(See full trace by running task with --trace)
       error    Failed to run `bin/rails db:migrate:queue`. Resolve and try again