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.

I made an error and used ExampleWeb instead of HelloI18nWeb. But still I am getting

** (ArgumentError) paths must begin with /, got: “\”/thermostat\“”
(phoenix 1.8.1) lib/phoenix/verified_routes.ex:757: Phoenix.VerifiedRoutes.verify_segment/2
(phoenix 1.8.1) lib/phoenix/verified_routes.ex:940: Phoenix.VerifiedRoutes.rewrite_path/4
(phoenix 1.8.1) lib/phoenix/verified_routes.ex:915: Phoenix.VerifiedRoutes.build_route/5
(phoenix 1.8.1) expanding macro: Phoenix.VerifiedRoutes.sigil_p/2
lib/helloi18n_web/live/thermostat_live.ex:29: Helloi18nWeb.ThermostatLive.render/1
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
Elixir

I see the docs are already 1.3, yet it has not been deployed to Hex. As a result you still have to use the manual install method right now.

currently away from home (and laptop), please remind me monday :slight_smile:

Lowercase ‘i’?

It seems like some sort of double quoting

.skip.

How about removing the ‘\’ ?

It’s bad formatting, I don’t have the backslash in code. I have this in code:

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

Not sure why the quotation marks are being changed here but in my editor it seems to be normal double quotes.

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!

No problem. I will wait. Thank you. I have tried to retype it but it’s still the same. I have noticed that the demo routex_example/mix.exs at main · BartOtten/routex_example · GitHub is still not on 1.8 Phoenix. Perhaps it’s related and this issue was introduced in 1.8.0 or 1.8.1? Because the for loop with navigate={alternative.slug} in <.link> works ok, no errors.

Hi Bart, have you take a look at it?

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

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>

Thanks, seems to be working.

oh, no. still getting the error in editor ;(

If it works in browser but the editor throws an error: burst the cache of the LSP-server. This should do the trick: It’s the equivalent of firing a cannon at a fly.

rm -Rf "_build" && mix phx.server

edit: interesting find. Which LSP are you using?

Hmm, this is weird. In VS Code this issue doesn’t show but in Zed I see it there no matter if if do the rm command and rebuild or not. I guess I will stick to VS Code. There it is ok, without error.

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

Let me guess: in Zed you use Expert LSP and in VScode you don’t? :slight_smile:

I am new to Zed, have seen it on videos of Jose etc.

I installed the probably default thing that popped up when I first clicked on .ex file I guess .

https://github.com/zed-extensions/elixir

This is the default.