@@ -121,29 +121,52 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
121121	sm .UseDefaultSignalHandling ()
122122	defer  sm .Release ()
123123
124- 	// Initialize with imported data, then fill in the gaps using the GOPATH 
125- 	rootAnalyzer  :=  newRootAnalyzer (cmd .skipTools , ctx , directDeps , sm )
126- 	m , l , err  :=  rootAnalyzer .InitializeRootManifestAndLock (root , gps .ProjectRoot (cpr ))
127- 	if  err  !=  nil  {
128- 		return  err 
124+ 	// Create empty manifest and lock 
125+ 	m  :=  & dep.Manifest {
126+ 		Constraints : make (gps.ProjectConstraints ),
127+ 		Ovr :         make (gps.ProjectConstraints ),
129128	}
129+ 	l  :=  & dep.Lock {}
130130
131+ 	// Initialize rootAnalyzer and gopathScanner 
132+ 	rootAnalyzer  :=  newRootAnalyzer (cmd .skipTools , ctx , directDeps , sm )
131133	gs  :=  newGopathScanner (ctx , directDeps , sm )
134+ 
135+ 	params  :=  gps.SolveParameters {}
136+ 
132137	if  cmd .gopath  {
138+ 		// Initialize with imported data, then fill in the gaps using the GOPATH 
139+ 		im , il , err  :=  rootAnalyzer .InitializeRootManifestAndLock (root , gps .ProjectRoot (cpr ))
140+ 		if  err  !=  nil  {
141+ 			return  err 
142+ 		}
143+ 
144+ 		if  im  !=  nil  {
145+ 			m  =  im 
146+ 		}
147+ 		if  il  !=  nil  {
148+ 			l  =  il 
149+ 		}
150+ 
133151		err  =  gs .InitializeRootManifestAndLock (m , l )
134152		if  err  !=  nil  {
135153			return  err 
136154		}
137- 	}
138155
139- 	rootAnalyzer .skipTools  =  true  // Don't import external config during solve for now 
156+ 		rootAnalyzer .skipTools  =  true  // Don't import external config during solve for now 
157+ 	}
140158
141- 	params  : =SolveParameters {
159+ 	params  =  gps.SolveParameters {
142160		RootDir :         root ,
143161		RootPackageTree : pkgT ,
144162		Manifest :        m ,
145163		Lock :            l ,
146- 		ProjectAnalyzer : rootAnalyzer ,
164+ 	}
165+ 
166+ 	if  cmd .gopath  {
167+ 		params .ProjectAnalyzer  =  rootAnalyzer 
168+ 	} else  {
169+ 		params .ProjectAnalyzer  =  dep.Analyzer {}
147170	}
148171
149172	if  ctx .Verbose  {
@@ -162,8 +185,8 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
162185	}
163186	l  =  dep .LockFromSolution (soln )
164187
165- 	rootAnalyzer .FinalizeRootManifestAndLock (m , l )
166188	if  cmd .gopath  {
189+ 		rootAnalyzer .FinalizeRootManifestAndLock (m , l )
167190		gs .FinalizeRootManifestAndLock (m , l )
168191	} else  {
169192		// Pick the direct dependencies from the above solution and add to manifest 
0 commit comments