@@ -674,78 +674,76 @@ defmodule Mix do
674674
675675 case Mix.State . get ( :installed ) do
676676 nil ->
677- :ok
677+ Application . put_all_env ( config , persistent: true )
678+ System . put_env ( system_env )
678679
679- ^ id when not force? ->
680- :ok
680+ installs_root =
681+ System . get_env ( "MIX_INSTALL_DIR" ) || Path . join ( Mix.Utils . mix_cache ( ) , "installs" )
681682
682- _ ->
683- Mix . raise ( "Mix.install/2 can only be called with the same dependencies in the given VM" )
684- end
683+ version = "elixir-#{ System . version ( ) } -erts-#{ :erlang . system_info ( :version ) } "
684+ dir = Path . join ( [ installs_root , version , id ] )
685685
686- Application . put_all_env ( config , persistent: true )
687- System . put_env ( system_env )
686+ if opts [ :verbose ] do
687+ Mix . shell ( ) . info ( "Mix.install/2 using #{ dir } " )
688+ end
688689
689- installs_root =
690- System . get_env ( "MIX_INSTALL_DIR" ) || Path . join ( Mix.Utils . mix_cache ( ) , "installs" )
690+ if force? do
691+ File . rm_rf! ( dir )
692+ end
691693
692- version = "elixir-#{ System . version ( ) } -erts-#{ :erlang . system_info ( :version ) } "
693- dir = Path . join ( [ installs_root , version , id ] )
694+ config = [
695+ version: "0.1.0" ,
696+ build_embedded: false ,
697+ build_per_environment: true ,
698+ build_path: "_build" ,
699+ lockfile: "mix.lock" ,
700+ deps_path: "deps" ,
701+ deps: deps ,
702+ app: :mix_install ,
703+ erlc_paths: [ "src" ] ,
704+ elixirc_paths: [ "lib" ] ,
705+ compilers: [ ] ,
706+ consolidate_protocols: Keyword . get ( opts , :consolidate_protocols , true )
707+ ]
694708
695- if opts [ :verbose ] do
696- Mix . shell ( ) . info ( "Mix.install/2 using #{ dir } " )
697- end
709+ started_apps = Application . started_applications ( )
710+ :ok = Mix.Local . append_archives ( )
711+ :ok = Mix.ProjectStack . push ( @ mix_install_project , config , "nofile" )
712+ build_dir = Path . join ( dir , "_build" )
698713
699- if force? do
700- File . rm_rf! ( dir )
701- end
714+ try do
715+ run_deps? = not File . dir? ( build_dir )
716+ File . mkdir_p! ( dir )
702717
703- config = [
704- version: "0.1.0" ,
705- build_embedded: false ,
706- build_per_environment: true ,
707- build_path: "_build" ,
708- lockfile: "mix.lock" ,
709- deps_path: "deps" ,
710- deps: deps ,
711- app: :mix_install ,
712- erlc_paths: [ "src" ] ,
713- elixirc_paths: [ "lib" ] ,
714- compilers: [ ] ,
715- consolidate_protocols: Keyword . get ( opts , :consolidate_protocols , true )
716- ]
717-
718- started_apps = Application . started_applications ( )
719- :ok = Mix.Local . append_archives ( )
720- :ok = Mix.ProjectStack . push ( @ mix_install_project , config , "nofile" )
721- build_dir = Path . join ( dir , "_build" )
722-
723- try do
724- run_deps? = not File . dir? ( build_dir )
725- File . mkdir_p! ( dir )
726-
727- File . cd! ( dir , fn ->
728- if run_deps? do
729- Mix.Task . rerun ( "deps.get" )
730- end
718+ File . cd! ( dir , fn ->
719+ if run_deps? do
720+ Mix.Task . rerun ( "deps.get" )
721+ end
731722
732- Mix.Task . rerun ( "deps.loadpaths" )
723+ Mix.Task . rerun ( "deps.loadpaths" )
733724
734- # Hex and SSL can use a good amount of memory after the registry fetching,
735- # so we stop any app started during deps resolution.
736- stop_apps ( Application . started_applications ( ) -- started_apps )
725+ # Hex and SSL can use a good amount of memory after the registry fetching,
726+ # so we stop any app started during deps resolution.
727+ stop_apps ( Application . started_applications ( ) -- started_apps )
737728
738- Mix.Task . rerun ( "compile" )
739- end )
729+ Mix.Task . rerun ( "compile" )
730+ end )
740731
741- for app <- Mix.Project . deps_apps ( ) do
742- Application . ensure_all_started ( app )
743- end
732+ for app <- Mix.Project . deps_apps ( ) do
733+ Application . ensure_all_started ( app )
734+ end
744735
745- Mix.State . put ( :installed , id )
746- :ok
747- after
748- Mix.ProjectStack . pop ( )
736+ Mix.State . put ( :installed , id )
737+ :ok
738+ after
739+ Mix.ProjectStack . pop ( )
740+ end
741+
742+ ^ id when not force? ->
743+ :ok
744+
745+ _ ->
746+ Mix . raise ( "Mix.install/2 can only be called with the same dependencies in the given VM" )
749747 end
750748 end
751749
0 commit comments