Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue parsing Mix Standalone path on Windows #1228

Closed
ericsalim opened this issue Jun 15, 2022 · 11 comments · Fixed by #1242
Closed

Issue parsing Mix Standalone path on Windows #1228

ericsalim opened this issue Jun 15, 2022 · 11 comments · Fixed by #1242
Labels
bug Something isn't working

Comments

@ericsalim
Copy link

Environment

  • Elixir & Erlang/OTP versions (elixir --version): Elixir 1.13.0 & Erlang/OTP 24
  • Operating system: Windows
  • How have you started Livebook (mix phx.server, livebook CLI, Docker, etc): Windows Command Line
  • Livebook version (use git rev-parse HEAD if running with mix): 0.6.1
  • Browsers that reproduce this bug (the more the merrier): N/A
  • Include what is logged in the browser console: ERROR!!! [Livebook] "C" does not point to a Mix project
  • Include what is logged to the server console: N/A

Current behavior

With Livebook 0.5, Mix Standalone runtime used to work fine. I set my environment variable like below:

SET LIVEBOOK_DEFAULT_RUNTIME=mix:C:/Users/my.name/livebook

After upgrading to the latest version, starting Livebook fails with this error:

ERROR!!! [Livebook] "C" does not point to a Mix project

I believe this is because the latest version adds support for [:FLAGS], messing file path splitting on Windows. Fortunately my Mix project lives on the same drive, so I can use /Users/my.name/livebook. But if my Mix project lives on another drive, then I see this as a blocking issue.

If this is an intended behavior and there's another way to do this, then the documentation should make this clearer.

Expected behavior

I expect either the file path to be parsed correctly, or the documentation to be made clearer.

@jonatanklosko
Copy link
Member

One way I see is supporting quotes to resolve ambiguity, but in shell this will require nested quotes like LIVEBOOK_DEFAULT_RUNTIME="mix:'C:/Users/my.name/livebook'", which is not really intuitive. @josevalim any other ideas?

@josevalim
Copy link
Contributor

Only split on the first : and let the runtime specific logic split on it again if necessary. I agree that the quotes are not very helpful, so we probably don’t need to support it.

@jonatanklosko
Copy link
Member

The parsing is already runtime-specific

"mix:" <> config ->
{path, flags} = parse_mix_config!(config)

It's just that there's a genuine ambiguity in mix:PATH[:FLAGS], because PATH may include :.

@josevalim
Copy link
Contributor

josevalim commented Jun 17, 2022 via email

@jonatanklosko
Copy link
Member

Actually, the flags can also include a file path, so it's always going to be unrealiable, unless we have a way to implicitly distinguish the parts 🤔

@josevalim
Copy link
Contributor

josevalim commented Jun 17, 2022

Ok, so I think we need two vars. LIVEBOOK_DEFAULT_RUNTIME and LIVEBOOK_DEFAULT_RUNTIME_FLAGS.

@jonatanklosko
Copy link
Member

For the mix runtime the flags are project path and mix run flags, so we would still need the quotes?

@josevalim
Copy link
Contributor

@jonatanklosko if we are looking at flags, then does it mean we need -- explicitly? If so, we can do this:

First split once on :-- to get the flags bit. Then split on the first :?

@josevalim
Copy link
Contributor

Ok. I actually think we should just check for Windows style paths. Check if we have <<letter, ?:, _::binary>> when letter in ?a..?z or letter in ?A..?Z immediately after "mix:". If you are still worried about false positives, then you can check : is followed by either / or \.

@josevalim josevalim added the bug Something isn't working label Jun 18, 2022
@jonatanklosko
Copy link
Member

Yeah, sounds good to me! Theoretically the path could have : anywhere, so either way the delimiter is heuristic-based, but I think it's fine.

@josevalim
Copy link
Contributor

I think in those cases people can use the quotes. But solving the immediate case for windows for be beneficial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants