@@ -113,10 +113,30 @@ public Path findNodePath() {
113
113
* @return string with absolute path to the binary
114
114
*/
115
115
public Path findYarnPath () {
116
+ Path yarnPathCandidate = null ;
116
117
117
- Path yarnPathCandidate ;
118
+ // 1. lookup by DEFAULT_YARN_PATH_VM_ARG
119
+ yarnPathCandidate = resolveFolderContaingBinary (
120
+ tryGetEnvOrSystemVariable (BinariesConstants .DEFAULT_YARN_PATH_VM_ARG ));
121
+ if (yarnPathCandidate != null ) {
122
+ info ("User specified default Yarn path will be used: '" + yarnPathCandidate
123
+ + ".' based on the '" + BinariesConstants .DEFAULT_YARN_PATH_VM_ARG + "' VM argument." );
124
+ return yarnPathCandidate ;
125
+ }
126
+ debug ("Could not resolve node path from '" + BinariesConstants .DEFAULT_NODE_PATH_VM_ARG
127
+ + "' VM argument." );
118
128
119
- // 1. lookup by PATH
129
+ // 2. lookup by YARN_PATH_ENV
130
+ yarnPathCandidate = resolveFolderContaingBinary (
131
+ tryGetEnvOrSystemVariable (BinariesConstants .YARN_PATH_ENV ));
132
+ if (yarnPathCandidate != null ) {
133
+ info ("User specified default yarn path will be used: '" + yarnPathCandidate
134
+ + ".' based on the '" + BinariesConstants .YARN_PATH_ENV + "' environment argument." );
135
+ return yarnPathCandidate ;
136
+ }
137
+ debug ("Could not resolve yarn path from '" + BinariesConstants .YARN_PATH_ENV );
138
+
139
+ // 3. lookup by PATH
120
140
yarnPathCandidate = resolveFolderContaingBinary (
121
141
ExecutableLookupUtil .findInPath (BinariesConstants .YARN_BINARY_NAME ));
122
142
if (yarnPathCandidate != null ) {
@@ -126,7 +146,7 @@ public Path findYarnPath() {
126
146
}
127
147
debug ("Could not resolve yarn path from OS PATH variable." );
128
148
129
- // 2 . lookup by OS query
149
+ // 4 . lookup by OS query
130
150
yarnPathCandidate = resolveFolderContaingBinary (
131
151
lookForBinary (BinariesConstants .YARN_BINARY_NAME ));
132
152
if (yarnPathCandidate != null ) {
@@ -137,8 +157,11 @@ public Path findYarnPath() {
137
157
}
138
158
debug ("Could not resolve yarn path from OS dynamic lookup." );
139
159
140
- debug ("Falling back to node path ..." );
141
- return findNodePath ();
160
+ // 5. use default, whether it is correct or not.
161
+ info ("Could not resolve yarn path. Falling back to default path: " + yarnPathCandidate );
162
+ yarnPathCandidate = new File (BinariesConstants .BUILT_IN_DEFAULT_YARN_PATH ).toPath ();
163
+
164
+ return yarnPathCandidate ;
142
165
}
143
166
144
167
private String lookForBinary (String binaryName ) {
0 commit comments