squasher
squasher copied to clipboard
Squasher couldn't load `database.yml`. Please, make sure that it's present and doesn't include any ruby code.
Hello, this issue happen recently. When I run squasher, this error occurred:
Squasher couldn't load
database.yml. Please, make sure that it's present and doesn't include any ruby code.
And this is my config/database.yml file:
default: &default
adapter: mysql2
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: docker
host: '127.0.0.1'
development:
<<: *default
database: tiengnhatit_development
test:
<<: *default
database: tiengnhatit_test
I think this is related to Ruby 3.1 which upgrades to Psych 4.0.
- Psych 4.0 changes
Psych.load
to usesafe_load
by default. You may need to use Psych 3.3.2 for migrating to this behavior. [Bug #17866]
(Source: https://www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-released/)
The corresponding PR can be found here:
- https://github.com/ruby/psych/pull/487
.safe_load
uses aliases: false
meaning that if you have something like this
default: &default
test:
<<: *default
the load won't work anymore. One solution would be to use YAML.unsafe_load
here
https://github.com/jalkoby/squasher/blob/714ac99d549adc05b31af664ad5354ccaeb6393f/lib/squasher/config.rb#L13
or maybe something like this YAML.load_file(path, aliases: true)
?
I think this is related to Ruby 3.1 which upgrades to Psych 4.0.
- Psych 4.0 changes
Psych.load
to usesafe_load
by default. You may need to use Psych 3.3.2 for migrating to this behavior. [Bug #17866](Source: https://www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-released/)
The corresponding PR can be found here:
.safe_load
usesaliases: false
meaning that if you have something like thisdefault: &default test: <<: *default
the load won't work anymore. One solution would be to use
YAML.unsafe_load
herehttps://github.com/jalkoby/squasher/blob/714ac99d549adc05b31af664ad5354ccaeb6393f/lib/squasher/config.rb#L13
or maybe something like this
YAML.load_file(path, aliases: true)
?
Thank you very much. I temporary resolved that by duplicate code in database.yml
development:
adapter: mysql2
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: docker
host: '127.0.0.1'
database: imeezi_development
test:
adapter: mysql2
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: docker
host: '127.0.0.1'
database: imeezi_test
@YutoYasunaga Yeah, that should do the trick too. You can revert it after you squashed the migrations.
However, I'd keep the issue open here, because it looks like it should be fixed. 👀
Hi there! Any news?
yes, version 0.7.2 is released