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

Plugin fails if Elixir lib dir contains spaces. #26

Open
ElectronicRU opened this issue Jun 9, 2021 · 3 comments
Open

Plugin fails if Elixir lib dir contains spaces. #26

ElectronicRU opened this issue Jun 9, 2021 · 3 comments

Comments

@ElectronicRU
Copy link

The detection uses IO.puts and removes spaces, which fails if e.g. under default Windows parameters, Elixir is installed under C:\Program Files. Using IO.write and not removing spaces would be the fix.

@tsloughter
Copy link
Collaborator

Thanks. Pls send a PR if you have time.

@mark-04
Copy link

mark-04 commented Aug 24, 2022

I had the same issue
Here in rebar_mix/src/rebar_mix_utils.erl, in the function get_lib_dir (line 42-53) we have the following case expression

case rebar_utils:sh("elixir -e \"IO.puts :code.lib_dir(:elixir)\"", [return_on_error]) of
    {ok, ElixirLibs_} ->
        filename:join(re:replace(ElixirLibs_, "\\s+", "", [global,{return,list}]), "../");
    _ ->
        erlang:error(missing_elixir)
end;

The insteresting part is re:replace(ElixirLibs_, "\\s+", "", [global,{return,list}])
It basically takes the path to Elixir and removes all whitespaces from it. And so if our path happens to start with, for instance, C:\Program Files (default when installing Elixir on windows), it becomes C:\ProgramFiles, resulting in an error.
I spent quite some time trying to figure out what the problem was, so I thought it is worth mentioning it

I'm not sure if it is a bug. I assume there is a valid reason why we would remove whitespaces from the path, and so I don't know if we should do something about it or keep it as is. I do think that it should be mentioned in the README, though. (e.g. in the requiremets section, we might include something like "Make sure that the path to your Elixir installation contains no significant whitespaces". I beleive, that could save a lot of debagging time for the future users).

@ferd
Copy link
Contributor

ferd commented Aug 24, 2022

No there's no good reason to remove whitespace from a path, it just makes it wrong. The proper fix is to escape and/or quote the path adequately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants