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

onelastdance
Hey there, Using the install script method recommended here on Ubuntu 24.04: And then running the following commands: iex&gt; :obser...
New
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
Ferenc
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 ...
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
harmon25
Hi All, I am bumping into a weird issue with an umbrella app while upgrading to latest Elixir 1.19.x + otp28. A couple apps in the umbr...
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
arnoldwolfe
I’ve been unable to deploy apps for over a week now due to the following error. It all started when Github has issues with GitHub Actions...
New
klo
Is there any way to go from a float 1.0 to 1.00 while retaining the float() type?
New
rayex
Hi, I am using the following versions: Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns] El...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
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
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
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

We're in Beta

About us Mission Statement