[ 
https://issues.apache.org/jira/browse/SOLR-18652?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jan Høydahl updated SOLR-18652:
-------------------------------
    Summary: solr start -e ignores the requested Solr home and writes the 
example into the installation directory  (was: bin/solr.cmd ignores --solr-home 
for examples, writing the example into the installation directory)

> solr start -e ignores the requested Solr home and writes the example into the 
> installation directory
> ----------------------------------------------------------------------------------------------------
>
>                 Key: SOLR-18652
>                 URL: https://issues.apache.org/jira/browse/SOLR-18652
>             Project: Solr
>          Issue Type: Bug
>          Components: cli
>            Reporter: Jan Høydahl
>            Priority: Major
>              Labels: cats, windows
>
> *Found by CATS*, the cross-platform CLI test framework proposed in SOLR-18642 
> — see [PR #5323|https://github.com/apache/solr/pull/5323]. A fix can land 
> before CATS is merged or after; if it lands first, please also drop the gate 
> on {{ExampleTest}} on that PR.
> h3. The gap
> {{bin/solr}} appends the resolved home to the arguments the example tool 
> receives ({{bin/solr:742}}):
> {code}
> PASS_TO_RUN_EXAMPLE+=("--solr-home" "$SOLR_HOME")
> {code}
> {{solr.cmd}}'s {{:set_solr_home_dir}} ({{solr.cmd:516\-534}}) sets 
> {{SOLR_HOME}} and jumps straight back to {{:parse_args}}. It never adds 
> anything to {{PASS_TO_RUN_EXAMPLE}}, and the {{run_example}} invocation at 
> {{solr.cmd:811}} therefore never carries the option.
> h3. Why the environment does not rescue it
> {{RunExampleTool}} falls back when the option is absent 
> ({{RunExampleTool.java:594\-606}}):
> {code:java}
> if (solrHomeArg != null) {
>   solrHomeDir = Path.of(solrHomeArg);
> } else {
>   String solrHomeProp = EnvUtils.getProperty("solr.home");
>   ...
>   } else if ("cloud".equals(exampleType)) {
>     solrHomeDir = exampleDir.resolve("cloud");
> {code}
> That fallback reads {{solr.home}}, but {{SOLR_HOME}} is mapped to 
> *{{solr.solr.home}}* ({{EnvToSyspropMappings.properties:15}}), and 
> {{EnvUtils.getProperty}} only falls back from camelCase to dot-separated 
> spellings of the key it was given — it does not consult the environment. So 
> {{solr.home}} is unset however the user supplied the home, and the branch 
> below it wins.
> h3. Result
> On Windows, {{solr start \-e cloud \-\-solr\-home X}} silently ignores {{X}} 
> and writes the example into {{%SOLR_TIP%\example\cloud}} — inside the 
> installation. For a non-cloud example it lands in {{server\solr}} instead. 
> The user gets no warning that the directory they asked for was discarded, and 
> a read-only installation directory fails outright.
> 🤖 AI Assisted



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to