elixir-cldr / cldr_dates_times

Date & times formatting functions for the Common Locale Data Repository (CLDR) package https://github.com/elixir-cldr/cldr
Other
68 stars 13 forks source link

Compile error "/priv/cldr/week_data.json": no such file or directory" #4

Closed kwando closed 5 years ago

kwando commented 6 years ago

I get some compile error when trying the latest version of ExCldr. Seesm like some files is missing / not downloaded correctly. Any idea how to move forward with this?

= Compilation error in file lib/cldr/calendar.ex ==
** (File.Error) could not read file "/Users/kwando/Desktop/api/deps/ex_cldr_dates_times/priv/cldr/week_data.json": no such file or directory
    (elixir) lib/file.ex:310: File.read!/1
    lib/cldr/config/config.ex:983: Cldr.Config.week_info/0
    lib/cldr/calendar.ex:66: (module)
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
$ mix deps
* ex_cldr 1.6.1 (Hex package) (mix)
  locked at 1.6.1 (ex_cldr) b1bc2c9d
  ok
* ex_cldr_currencies 1.0.0 (Hex package) (mix)
  locked at 1.0.0 (ex_cldr_currencies) 471c6374
  ok
* ex_cldr_numbers 1.4.4 (Hex package) (mix)
  locked at 1.4.4 (ex_cldr_numbers) 88930ca7
  ok
* ex_cldr_dates_times (Hex package) (mix)
  locked at 1.3.0 (ex_cldr_dates_times) 3628a394
  the dependency build is outdated, please run "mix deps.compile"
kipcole9 commented 6 years ago

Apologies for the inconvenience. I'm not seeing this issue on my integration test app so I'm going to have to dive a bit deeper to see why you are getting this error.

The file priv/cldr/week_data.json is actually contained in the lib ex_cldr. So the error from not finding the file in .../deps/ex_cldr_dates_times/priv/cldr/week_data.json is surprising.

Would you mind running:

mix deps.clean ex_cldr_dates_times
mix deps.get
mix deps.compile --force

And let met know if this produces a different result? In parallel I'll dig into the code to see how it might possibly pick up the wrong directory.

kwando commented 6 years ago

No need to apologize, I'm thanking you for building/maintaining this library. :heart:

Yep, tried cleaning and recompiling a few times in different combinations with no success. Though I think I found a lead for you, seems to be related to the configuration somehow. It works with an empty config.exs, but it breaks when configured like this:

use Mix.Config

config :ex_cldr,
   default_locale: "sv",
   locales: ["en", "sv"],
   data_dir: "./priv/cldr"

Below is a repository with a reproduction https://github.com/kwando/cldr_bug_repro

kipcole9 commented 6 years ago

OK, i understand the source of the problem. One issue I have fixed with an updated version 1.6.2 ex_cldr. There was a bug whereby the Cldr.Config.client_data_dir/0 was being used to open static content instead of Cldr.Config.cldr_data_dir/0. Upgrading to with mix deps.update ex_cldr will fix this

The second issue which i can't reasonably fix until ex_cldr version 2.0 is that the :data_dir config parameter will need to be an absolute path, not a relative one. I appreciate this isn't very friendly but its a consequence of the compile time downloading of locales. When that is happening, the current dir is actually the home dir of the ex_cldr dependency; not the home dir of your app. This results in a bogus Cldr.Config.client_data_dir/0 resolution. Hence the need to use an absolute path.

Would you mind following the above and letting me know if that is working for you?

There is a lot simplification in the architecture and compilation phase in ex_cldr version 2.0 but its going to take another couple of months to get to a release candidate.

kwando commented 6 years ago

Updating ex_cldr to 1.6.2 works without further changes, even if I leave data_dir as a relative path.

I don't really have a need to specify that option anyway so I can just remove that config option.

$ mix deps.update --all
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
  abnf2 0.1.2
  decimal 1.5.0
  ex_cldr_currencies 1.0.0
  ex_cldr_dates_times 1.3.0
  ex_cldr_numbers 1.4.4
  poison 3.1.0
Upgraded:
  ex_cldr 1.6.1 => 1.6.2
* Updating ex_cldr (Hex package)