[ 
https://issues.apache.org/jira/browse/CAMEL-25236?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18121865#comment-18121865
 ] 

Claus Ibsen commented on CAMEL-25236:
-------------------------------------

Decision: no virtual file system. camel run --example runs every example in a 
child JVM whose working directory is the example folder (as the TUI already 
does), so relative file paths (file:orders, out/, parked/) resolve to the 
example files wherever camel run is started. One code path for all examples, no 
change to camel-file; camel export of an example is unaffected.

_Claude Code on behalf of davsclaus_

> camel-jbang - camel run --example should work from any folder for examples 
> that read files
> ------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25236
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25236
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jbang
>            Reporter: Claus Ibsen
>            Priority: Minor
>
> *Problem*
> {{camel run --example=route/content-based-router}} (and other examples that 
> read or write files, such as {{fail-well/error-handling}}) only works when 
> run from the example's own folder. The example is extracted (or downloaded) 
> to a temp folder, but the JVM keeps the working directory it was started in, 
> so {{file:orders}} reads an auto-created, empty {{./orders}} in the current 
> folder and the example processes nothing. A JVM cannot change its own working 
> directory, and setting {{user.dir}} is unsupported.
> The TUI works around it by starting the example in a separate process whose 
> working directory is the example folder. The CLI should not need a different 
> code path depending on whether an example has files.
> *Idea*
> Put the example's data files on the classpath (as the routes are), and let 
> camel-file read them from there, as a kind of virtual ("fake") file system 
> for the example. For example, camel run could tell camel-file that relative 
> file paths of this run resolve against the example's files, so 
> {{file:orders}} consumes the example's {{orders}} folder, wherever {{camel 
> run}} is started.
> *Questions to settle*
> * Where the virtual file system lives: a camel-file feature (a base directory 
> or resolver for relative paths, set by camel run for examples), or something 
> in camel-jbang only.
> * Writing: examples also write files ({{parked/}}, {{out/}}). The classpath 
> is read-only, so writes need a real folder (the extracted temp folder, or a 
> folder in the current directory), and the user should be able to find what 
> was written.
> * Consumer semantics: {{noop}}, idempotent repository, move/delete after 
> processing, and file watching should behave the same as with a real folder.
> * Scope: bundled examples and examples downloaded from GitHub alike; {{camel 
> export}} of an example should still produce a normal project with real files.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to