oliverandrich

oliverandrich

Question about a strange error in VSCode using ElixirLS, Cldr and Phoenix

I am using Cldr in my phoenix project, which just works flawlessly. I also run credo and dialyxir on the code base. No problems at all. But I get in vscode the following error.

(Cldr.UnknownBackendError) The backend Jocasta.Cldr is not known or not a backend module.

Stacktrace:
  │ (ex_cldr 2.18.2) lib/cldr.ex:547: Cldr.validate_backend!/1
  │ (ex_cldr 2.18.2) lib/cldr/plug/plug_set_locale.ex:363: Cldr.Plug.SetLocale.validate_app_and_scope!/2
  │ (ex_cldr 2.18.2) lib/cldr/plug/plug_set_locale.ex:331: anonymous fn/1 in Cldr.Plug.SetLocale.validate_apps/2
  │ (elixir 1.11.3) lib/enum.ex:1411: Enum."-map/2-lists^map/1-0-"/2
  │ (ex_cldr 2.18.2) lib/cldr/plug/plug_set_locale.ex:329: Cldr.Plug.SetLocale.validate_apps/2
  │ (ex_cldr 2.18.2) lib/cldr/plug/plug_set_locale.ex:172: Cldr.Plug.SetLocale.init/1
  │ (plug 1.11.0) lib/plug/builder.ex:304: Plug.Builder.init_module_plug/4
  │ (plug 1.11.0) lib/plug/builder.ex:288: anonymous fn/5 in Plug.Builder.compile/3

This error shows up as soon as I add this plug to the browser pipeline in router.ex.

    plug Cldr.Plug.SetLocale,
      apps: [cldr: Jocasta.Cldr, gettext: Jocasta.Gettext],
      from: [:accept_language]

Where Jocasta.Cldr looks like that.

defmodule Jocasta.Cldr do
  use Cldr,
    gettext: Jocasta.Gettext,
    providers: [Cldr.Number, Cldr.List, Cldr.Calendar, Cldr.DateTime]
end

When I validate the module in iex, I get no errors either.

iex(1)> Cldr.validate_backend(Jocasta.Cldr)
{:ok, Jocasta.Cldr}

Any hints how I can get rid of the error in vscode?

Marked As Solved

oliverandrich

oliverandrich

@kip suggests adding something like the following code to the router.ex to fix a compilation error.

https://github.com/elixir-cldr/cldr/issues/135

# Adding the require forces the compiler
# to process this module now
require Jocasta.Cldr

It doesn’t seem to be necessary as of ex_cldr 2.14.1, but it sees to be necessary in the VSCode + ElixirLS context.

Where Next?

Popular in Questions Top

dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29603 241
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43487 311
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement