thoughtbot / suspenders

A Rails template with our standard defaults.
https://thoughtbot.com
MIT License
4.01k stars 530 forks source link

Running `bin/setup` fails after generating a new app #1224

Open stevepolitodesign opened 3 weeks ago

stevepolitodesign commented 3 weeks ago

When I run bin/setup in a newly generated app, I get the following error:

       rails  db:prepare
Created database 'fail_development'
Created database 'fail_test'

Congratulations! You just pulled our suspenders.

~/Sites via šŸ’Ž v3.3.0 on ā˜ļø    took 3m59s
āÆ v

~/Sites via šŸ’Ž v3.3.0 on ā˜ļø    took 2s
āÆ cd fail

fail on ī‚  main [?] via īœ˜ v22.1.0 via šŸ’Ž v3.3.0 on ā˜ļø
āÆ bin/setup
== Installing dependencies ==
The Gemfile's dependencies are satisfied
yarn install v1.22.17
[1/4] šŸ”  Resolving packages...
[2/4] šŸšš  Fetching packages...
[3/4] šŸ”—  Linking dependencies...
warning " > @thoughtbot/eslint-config@1.0.2" has unmet peer dependency "jest@>= 25.0.0".
warning " > @thoughtbot/eslint-config@1.0.2" has unmet peer dependency "typescript@>= 4.0.0".
warning "@thoughtbot/eslint-config > @typescript-eslint/eslint-plugin > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[4/4] šŸ”Ø  Building fresh packages...
āœØ  Done in 0.88s.

== Preparing database and adding development seed data ==
Database 'fail_development' already exists
Database 'fail_test' already exists
/Users/polito/Sites/fail/db/schema.rb doesn't exist yet. Run `bin/rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /Users/polito/Sites/fail/config/application.rb to limit the frameworks that will be loaded.
bin/setup:9:in `system': Command failed with exit 1: bin/rails (RuntimeError)
        from bin/setup:9:in `system!'
        from bin/setup:24:in `block in <main>'
        from /Users/polito/.asdf/installs/ruby/3.3.0/lib/ruby/3.3.0/fileutils.rb:240:in `chdir'
        from /Users/polito/.asdf/installs/ruby/3.3.0/lib/ruby/3.3.0/fileutils.rb:240:in `cd'
        from bin/setup:16:in `<main>'

About your application's environment
Rails version             7.2.0
Ruby version              ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
RubyGems version          3.5.6
Rack version              3.1.7
Middleware                ActionDispatch::HostAuthorization, Rack::Sendfile, ActionDispatch::Static, ActionDispatch::Executor, ActionDispatch::ServerTiming, ActiveSupport::Cache::Strategy::LocalCache::Middleware, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, ActionDispatch::RemoteIp, Sprockets::Rails::QuietAssets, Rails::Rack::Logger, ActionDispatch::ShowExceptions, WebConsole::Middleware, ActionDispatch::DebugExceptions, ActionDispatch::ActionableExceptions, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ContentSecurityPolicy::Middleware, ActionDispatch::PermissionsPolicy::Middleware, Rack::Head, Rack::ConditionalGet, Rack::ETag, Rack::TempfileReaper
Application root          /Users/polito/Sites/fail
Environment               development
Database adapter          postgresql
Database schema version   0
stevepolitodesign commented 3 weeks ago

Our application template invokes bin/rails db:prepare, which is what the Rails does in its bin/setup script.

Even invoking bin/rails db:prepare again within the newly generated application has no affect.

Running bin/rails db:migrate did the trick.

stevepolitodesign commented 3 weeks ago

I wonder if we need to remove rails_command "db:prepare" from the application template and instead add it to our custom setup script?