Claus Ibsen created CAMEL-26931:
-----------------------------------

             Summary: camel-jbang - standalone commands: dependency copy mixes 
library versions, a local camel-cli.properties hides the global one, and plugin 
add stores plugins that do not exist
                 Key: CAMEL-26931
                 URL: https://issues.apache.org/jira/browse/CAMEL-26931
             Project: Camel
          Issue Type: Bug
          Components: camel-jbang
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found by a scan of the Camel CLI on 2026-11-13, with the unpacked 
4.24.0-SNAPSHOT camel-launcher on macOS (JDK 25). *(exp)* means reproduced by 
experiment, *(read)* means traced in the code. Paths are relative to 
{{dsl/camel-jbang/}}, and line numbers are from main at that time. Earlier 
findings of this kind: CAMEL-26901, CAMEL-26911 to CAMEL-26914.

h3. 1. camel dependency copy puts several versions of a library in lib/ (exp, 
high)

{{DependencyCopy.java:99}} resolves each GAV on its own and only skips a JAR 
whose file name is already there. A route with kafka, https, aws2-s3 and 
mongodb gave 96 JARs, among them {{httpclient5}} 5.6.4 and 5.6.5, {{httpcore5}} 
5.4.3 and 5.4.4, {{slf4j-api}} 1.7.36 and 2.0.20. This is CAMEL-26901 item 1 in 
another command. Resolve all GAVs in one request.

h3. 2. A local ./camel-cli.properties hides the whole global configuration 
(exp, high)

{{CommandLineHelper.getUserConfigurationFile}} (143-151) uses the local file 
when it exists, else the global one, and never merges them. A project file with 
one key silently drops the user's global {{repos}}, {{camel-version}} or 
{{runtime}}, while {{camel config list}} shows both. 
{{camel-jbang-configuration.adoc:84}} ("takes precedence") reads as a merge. 
Load the global file and lay the local one over it.

h3. 3. camel plugin add stores plugins it never checked (exp)

{{PluginAdd.java:84-160,179}} only downloads when it picks a community release 
itself. {{camel plugin add kubernets}} prints "Plugin kubernets added" and 
exits 0; after that every {{camel run}} and {{camel export}} fails with a 
40-line Maven stack trace, because {{PluginHelper.getActivePlugins}} (359-414) 
treats an entry without {{appliesTo}} as a contributor to run and export. 
Resolve before saving and exit 3 with a suggestion; skip a contributor that 
cannot be resolved with a warning.

h3. 4. Errors for bad versions and config values (exp)

* A wrong {{--camel-version}} gives exit 70 and a 42-line trace ("Cannot 
resolve dependencies in https://repo1.maven.org/maven2";) in catalog, doc and 
validate ({{CatalogBaseCommand.java:134}}, {{CatalogVersionMixin}} 76-79). Say 
"Camel version 9.9.9 not found" with exit 3.
* {{camel version set}} takes any value and exits 0; with no argument it is a 
no-op; {{--reset}} also removes {{repos}} and {{runtime}} 
({{VersionSet.java:63-79}}).
* A bad config value ({{camel config set runtime=springboot}}) makes every 
command with {{--runtime}} fail with "DefaultValueProvider failed for option 
runtime", naming neither the file, the key nor the value 
({{CommandLineHelper.java:240+}}).
* {{camel config set}} accepts any key or value; {{config unset nope}} exits 0 
while {{config get nope}} exits 3.

h3. 5. camel doctor reports Maven as failed on every SNAPSHOT CLI (exp)

{{Doctor.java:185-187}} resolves with {{useApacheSnapshots=false}}, so a fresh 
home gets "Artifact resolution failed ... camel-api:jar:4.24.0-SNAPSHOT" and 
exit 1. Pass {{version.endsWith("-SNAPSHOT")}} as {{DependencyCopy}} does.

h3. 6. camel init writes the wrong file (exp)

* {{file.contains("source")}} (line 155) is checked on the whole path, so 
{{src/main/resources/kamelets/my-filter.kamelet.yaml}} becomes a source Kamelet 
("resources" contains "source").
* A file given as {{./x.yaml}} ignores {{--dir}} (line 229).
* {{camel init my-route.java}} and {{1bad.java}} write classes that do not 
compile, with exit 0.

h3. 7. Missing input file: exit codes and channels differ (exp)

{{dependency list/copy/sbom nosuch.yaml}} print "Path does not exist" on stdout 
and exit 1 ({{ProjectExporter.java:175-177}}); {{transform route nosuch.yaml}} 
exits 1 without naming the file ({{SourceHelper.java:154}} wraps the 
FileNotFoundException); with {{--format=java}} it exits 66 like script, 
explain, harden and overview.

h3. 8. camel eval expression output (exp)

{{Run.java:1382}} prints "Camel Main: transform (state: Running)" on stdout, so 
{{X=$(camel eval ...)}} gets two lines; a syntax error prints the remote 
30-line trace before the ERROR line ({{EvalExpressionCommand.java:207-210}}); 
no {{--json}}.

h3. 9. camel infra stop --kill can kill an unrelated process (read)

{{InfraStop.java:70-79}} and {{InfraBaseCommand.findRunningServices}} (138-176) 
take any live PID with an {{infra-*.json}} file as the service. The PID-reuse 
problem of CAMEL-26911 item 1 on a separate code path.

h3. 10. Smaller

* {{transform route --format=java --output=Out.java}} writes {{class Up}} into 
Out.java ({{TransformRoute.java:198}}).
* {{dependency update}} drops the final newline, and writes CRLF on Windows 
({{DependencyUpdate.java:248,319,348}}).
* {{camel wrapper}} on a SNAPSHOT pins a Central URL that is 404; {{camelw}} 
prints its download messages on stdout and downloads straight to the final 
path, so a Ctrl-C leaves a corrupt JAR.
* {{catalog --filter}} only matches whole names ({{--filter=aws2}} lists 
nothing); {{--sort}} has no {{since}}.
* Help: {{EvalCommand.java:22}} says "use transform --help"; a required 
argument without {{paramLabel}} puts its description into the error; {{camel 
update run}} options are camelCase ({{--dryRun}}); {{doc <eip>}} prints an 
empty "Since:"; {{paramLabel = "<file>"}} shows as {{<<file>>}} (run, init, 
nano, script, edit, validate yaml).
* {{camel bind}} reads Kamelets from the {{main}} branch of camel-kamelets on 
GitHub ({{PipeProvider.java:107}}): newer than the CLI and not offline; the 
"Kamelet not found" branch at line 151 is dead.
* {{plugin get}} with no plugins prints nothing; {{infra ps}} with nothing 
running prints an empty header.
* No {{--json}} on {{version}}, {{version get}}, {{eval expression}}, 
{{overview}}, {{dependency list}}, {{transform route}}, {{init --list}}. 
{{dependency list}} takes 2.4-5.9 s (a full export) and leaves 
{{.camel-jbang/}} behind.
* {{HOME=<dir>}} does not isolate the CLI on macOS (Java takes {{user.home}} 
from the passwd entry), so sandboxes and agents need {{-Duser.home}}. An 
environment variable for the CLI home would make that easy.

h3. Came out clean

catalog and doc {{--json}}, not-found handling, config and plugin JSON, infra 
unknown service (exit 3), transform dataweave, script, explain and harden error 
handling, the completion script, and every option in the 62 documented command 
lines.

_Claude Code on behalf of Claus Ibsen_



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

Reply via email to