Skip to content

[Feature Request]Makes executable works when not in Elixir's directory. #3

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bin/elixir
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
#!/bin/sh
erl -I include -noshell -pa ebin -eval "elixir:boot(), elixir:require_file(\"$1\", [\".\"]), halt()."

SCRIPT=$(readlink -f $0)
SCRIPT_PATH=`dirname $SCRIPT`
ELIXIR_PATH=`cd $SCRIPT_PATH; cd ..; pwd`

ELIXIR_PATH=$ELIXIR_PATH erl -I $ELIXIR_PATH/include -noshell -pa $ELIXIR_PATH/ebin -eval "elixir:boot(), elixir:require_file(\"$1\", [\".\"]), halt()."
8 changes: 6 additions & 2 deletions src/elixir.erl
Original file line number Diff line number Diff line change
@@ -12,7 +12,10 @@ boot() ->
% the default binding is Object, which at this point is not defined.
load_core_classes() ->
Dirname = filename:dirname(?FILE),
Basepath = filename:join([Dirname, "..", "lib"]),
Basepath = case os:getenv("ELIXIR_PATH") of
false -> filename:join([Dirname, "..", "lib"]);
Path -> filename:join([Path, "lib"])
end,
Loader = fun(Class) ->
Filepath = filename:join(Basepath, Class),
{ok, Binary} = file:read_file(Filepath),
@@ -41,7 +44,8 @@ require_file(Path) ->
Dirname = filename:dirname(?FILE),
Paths = [
filename:join([Dirname, "..", "lib"]),
filename:join([Dirname, "..", "test", "elixir"])
filename:join([Dirname, "..", "test", "elixir"]),
"."
],
require_file(Path ++ ".ex", Paths).