@@ -64,13 +64,31 @@ defmodule Expert.Port do
6464 # We launch expert by asking the version managers to provide an environment,
6565 # which contains path munging. This initial environment is present in the running
6666 # VM, and needs to be undone so we can find the correct elixir executable in the project.
67- defp reset_env ( "asdf" , _root_path ) do
68- orig_path = System . get_env ( "PATH_SAVE" , System . get_env ( "PATH" ) )
67+ defp reset_env ( "asdf" , root_path ) do
68+ { env , _ } = System . cmd ( "asdf" , ~w( env elixir) , cd: root_path )
69+
70+ env =
71+ env
72+ |> String . trim ( )
73+ |> String . split ( "\n " )
74+ |> Enum . map ( fn key_and_value ->
75+ [ key , value ] =
76+ key_and_value
77+ |> String . split ( "=" , parts: 2 )
78+ |> Enum . map ( & String . trim / 1 )
79+
80+ { key , value }
81+ end )
82+ |> Enum . reject ( & is_nil / 1 )
83+
84+ asdf_path =
85+ case List . keyfind ( env , "ASDF_INSTALL_PATH" , 0 ) do
86+ { _ , path } -> Path . join ( path , "../../../shims" )
87+ _ -> ""
88+ end
6989
7090 Enum . map ( System . get_env ( ) , fn
71- { "ASDF_ELIXIR_VERSION" , _ } -> { "ASDF_ELIXIR_VERSION" , nil }
72- { "ASDF_ERLANG_VERSION" , _ } -> { "ASDF_ERLANG_VERSION" , nil }
73- { "PATH" , _ } -> { "PATH" , orig_path }
91+ { "PATH" , path } -> { "PATH" , "#{ asdf_path } :#{ path } " }
7492 other -> other
7593 end )
7694 end
@@ -169,7 +187,7 @@ defmodule Expert.Port do
169187 raise ArgumentError , "Operating system #{ inspect ( os_tuple ) } is not currently supported"
170188 end
171189
172- defp ensure_charlists ( environment_variables ) do
190+ def ensure_charlists ( environment_variables ) do
173191 Enum . map ( environment_variables , fn { key , value } ->
174192 # using to_string ensures nil values won't blow things up
175193 erl_key = key |> to_string ( ) |> String . to_charlist ( )
0 commit comments