This error is interesting: it pops up once when running script/setup, but after either:
Money.default_currency = Money::Currency.new(Spree::Config[:currency]) with Money.default_currency = Money::Currency.new('AUD') and then running the script/setup and then reverting the change the error disappears 🤔 https://openfoodnetwork.slack.com/archives/C2GQ45KNU/p1620397593134200
Linked issue: #7613
Timeline: 1 week. Impact: better onboarding experience for new developers ✨
Could it be related to cache?
What if you try doing rails tmp:cache:clear in between?
I noticed another weird thing, when I start rails console 2 times in a row after clearing the cache, it can load 2 different values as the default currency.
config/application.yml "AUD"Might it have something to do with Figaro loading the .yml file after Spree is loaded in some cases? :thinking:
Related parts:
https://github.com/openfoodfoundation/openfoodnetwork/blob/99cf23df265ea97a1b6485c08d464da3298670b9/app/models/spree/app_configuration.rb#L41
https://github.com/openfoodfoundation/openfoodnetwork/blob/99cf23df265ea97a1b6485c08d464da3298670b9/config/initializers/money.rb#L2
Ah the mystery deepens! Thanks for the input @viktorsmari ! I'll try clearing my rails cache and see if the error re-appears 👍
I didn't know about the second point (default currency switching from "USD" to "AUD"). It points perhaps to a bigger problem: that we have two configs rather than one. For this ticket I guess we should fix only the default currency error and either always use "USD" or "AUD". But I'm aslo wondering if we should raise a separate ticket to merge all configs into one..? 🤔
So with @apricot12 we made a videoconference to talk about reproducibility of this issue. Here is a way to currently reproduce it systematically:
cd /tmp/
git clone $SOME_OFN_REPOSITORY_CLONE
cd /tmp/openfoodnetwork
bundle exec rails server
./script/setup
So, much thanks to @apricot12 who excavated the reproduction process. :pray:
Most helpful comment
Could it be related to cache?
What if you try doing
rails tmp:cache:clearin between?I noticed another weird thing, when I start
rails console2 times in a row after clearing the cache, it can load 2 different values as the default currency.config/application.yml"AUD"Might it have something to do with Figaro loading the
.ymlfile after Spree is loaded in some cases? :thinking:Related parts:
https://github.com/openfoodfoundation/openfoodnetwork/blob/99cf23df265ea97a1b6485c08d464da3298670b9/app/models/spree/app_configuration.rb#L41
https://github.com/openfoodfoundation/openfoodnetwork/blob/99cf23df265ea97a1b6485c08d464da3298670b9/config/initializers/money.rb#L2