Ferenc

Ferenc

Compilation error verified path: (ArgumentError) paths must begin with /

I have installed it on Phoenix 1.8.1 (without authentication or other packages and got 2 problems).

I had to set up things manually the 2nd way because the mix routex.install command produced this error in terminal:

$ mix routex.install
** (Mix) The task “routex.install” could not be found

And the second issue is that when trying to sue the code in live view

<.link navigate={\~p"/thermostat"}>{gettext("Thermostat")}

then this part → <.link is showing this error:

** (FunctionClauseError) no function clause matching in anonymous fn/1 in Routex.Branching.build_case/6

The following arguments were given to anonymous fn/1 in Routex.Branching.build_case/6:

    \# 1

    {:->, \[newlines: 1\], \[\[0\], {{:., \[\], \[Phoenix.VerifiedRoutes, :sigil_p\]}, \[\], \[{:<<>>, \[line: 29\], \["/thermostat"\]}, \[\]\]}\]}

(routex 1.2.4) lib/routex/branching.ex:207: anonymous fn/1 in Routex.Branching.build_case/6

(elixir 1.17.3) lib/enum.ex:4796: Enum.uniq_list/3

(routex 1.2.4) lib/routex/branching.ex:207: Routex.Branching.build_case/6

expanding macro: Helloi18nWeb.Router.RoutexHelpers.sigil_p/2

lib/helloi18n_web/live/thermostat_live.ex:29: Helloi18nWeb.ThermostatLive.render/1

(phoenix_live_view 1.1.13) expanding macro: Phoenix.Component.sigil_H/2

lib/helloi18n_web/live/thermostat_live.ex:6: Helloi18nWeb.ThermostatLive.render/1

the router looks like this:

preprocess_using ExampleWeb.RoutexBackend do
scope “/”, Helloi18nWeb do
pipe_through :browser

  get "/", PageController, :home
  get "/products", PageController, :home
  #
  live "/thermostat", ThermostatLive
end

end

the lang switcher example:

<.link :for={alternative <- Routes.alternatives(@url)} class="button" rel="alternate" hreflang={alternative.attrs.language} navigate={alternative.slug} > <.button class={if(alternative.match?, do: "bg-\[#FD4F00\]", else: "")}> {alternative.attrs.language_display_name}

works without any errors.

Marked As Solved

BartOtten

BartOtten

I’ve found the issue. The devil is in the details:

So far, all examples have used / to delimit a regular expression. However, sigils support 8 different delimiters:

~r/hello/
~r|hello|
~r"hello"
~r'hello'
~r(hello)
~r[hello]
~r{hello}
~r<hello>

https://hexdocs.pm/elixir/main/sigils.html

So both () and " are delimiters, but only the first one is used as such. As a result, the argument for the sigil is "/termostat" instead of /termostat. The former not starting with a / but a "

Fix: use either ( or , not both
<.link navigate={~p“/thermostat”}>{gettext(“Thermostat”)}</.link>

or

<.link navigate={~p(/thermostat)}>{gettext(“Thermostat”)}</.link>

Also Liked

BartOtten

BartOtten

Sorry for the delay; some tasks popped up last few days. Hope to have a look at it later today.

BartOtten

BartOtten

Thanks for the confirmation. Package published to routex | Hex

BartOtten

BartOtten

Please remove the quotes and type them again. Have been bitten once or twice in life by not-exactly-the-correct-quotes.

Will return problem hunting at monday!

BartOtten

BartOtten

Not sure why, but there is unexpected metadata causing the clause to fail. Will publish a fix on Github in minutes.

BartOtten

BartOtten

This should fix it either way:

Could you try using this as dep?

{:routex, git: "https://github.com/BartOtten/routex"}

Where Next?

Popular in Troubleshooting Top

alexlanderzander
Hello everyone, I’m working on a blockchain project in Elixir and I’m implementing some of the core cryptography in a Rust NIF using Rus...
New
tomekowal
Hi! I am trying to pinpoint why my project has issue on incremental compilation when running tests in elixir 1.19.0-rc.0-otp-26 I am ru...
New
chocolatedonut
Besides (over)logging every code-path leading to Repo.insert_all, is it possible to make Postgrex and/or ecto_sql log the exact, failing ...
New
mooreryan
In a project I’m working on, I cannot get tests with breakpoints or pry working. Here is an example in a new mix project. Create a fresh...
New
jdj_dk
Hi everyone. I’m trying to setup a small cluster with three nodes. I’m using libcluster as I have before. But my nodes doesn’t have a us...
New
mohammedzeglam
I am trying deploy phoenix app to cloud run every thing works locally fine using public IP but when i deployed to cloud run the app could...
New
pikdum
Hello, I’m trying to upgrade a pretty large project from Elixir 1.18.4 to Elixir 1.19.1 (1321 modules), but seeing some compiler warning...
New
jason.o
I don’t get an error directly related to Paraxial, but removing that dependency stopped the crash. Has anyone experienced a similar issu...
New
michaelterryio
Hey, I’ve got a project with several path dependencies. Some are phoenix apps, but this likely isn’t relevant. I don’t fully understand...
New
onelastdance
Hey there, Using the install script method recommended here on Ubuntu 24.04: And then running the following commands: iex&gt; :obser...
New

Other popular topics Top

jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
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
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement