Skip to content

Issue #2402 : Support ~ (tilde) at start of path to resolve ${user.home} - #8256

Merged
hansva merged 1 commit into
apache:mainfrom
mattcasters:issue-2402
Sep 4, 2026
Merged

Issue #2402 : Support ~ (tilde) at start of path to resolve ${user.home}#8256
hansva merged 1 commit into
apache:mainfrom
mattcasters:issue-2402

Conversation

@mattcasters

Copy link
Copy Markdown
Contributor

Fixes #2402

Description

In Apache Hop, specifying a path starting with ~ (e.g. ~/testenv or ~\testenv on Windows) resulted in a folder literally named ~ created inside the Hop installation base directory (user.dir), because neither standard Java nor Apache Commons VFS expands tilde to the user's home directory.

This PR adds system-wide support for ~ (tilde) at the start of paths to mean ${user.home} across Apache Hop on all platforms (including Windows with backslash \ separators).

Changes

  • Core Virtual File System (hop-core):
    • Added HopVfs.resolveHomeDirectory(String path, IVariables variables) and HopVfs.resolveHomeDirectory(String path).
      • Expands exact ~, ~/..., ~\..., as well as file://~... and file:~... to ${user.home}.
      • Preserves non-start occurrences (e.g. /opt/hop/~, foo~bar, s3://bucket/~/key) and non-separator suffixes (e.g. ~username, ~temp).
      • Uses ${user.home} from IVariables when provided, falling back to System.getProperty("user.home").
    • Integrated resolveHomeDirectory into HopVfs.resolveWith() so that all file operations (getFileObject, fileExists, getInputStream, etc.) resolve tilde paths transparently.
    • Updated HopVfs.isAbsolutePath() to recognize tilde paths as absolute so they are not treated as relative to the working directory.
  • Projects Plugin (hop-misc-projects):
    • Updated PathVariableReplacer.isCandidatePathValue() to accept tilde paths (~, ~/..., ~\...) for project variable rewriting.
    • Updated ProjectsMetadataExporter.resolveExportFilename() to use HopVfs.isAbsolutePath().
  • Git Plugin (hop-misc-git):
    • Delegated CaseInsensitiveIgnores.replaceUserHome() to HopVfs.resolveHomeDirectory().
  • Documentation:
    • Updated vfs.adoc documenting ~ under the File provider with POSIX and Windows syntax rules and examples.
    • Updated variables.adoc with a dedicated section on the ~ user home shortcut.
    • Updated projects-environments.adoc documenting that ~ can be used in the project Home folder and environment variables.
  • Unit Tests:
    • Added unit test coverage in HopVfsTest and PathVariableReplacerTest.

…ser.home}

- HopVfs: Add resolveHomeDirectory(path, variables) and resolveHomeDirectory(path)
  to resolve ~ (bare ~), ~/... and ~\... (Windows backslash) as well as file://~...
  to ${user.home}, while preserving non-start occurrences and non-separator suffixes.
- HopVfs: Update resolveWith() to expand leading tildes before scheme checking,
  and update isAbsolutePath() to recognize tilde paths.
- hop-misc-projects: Recognize tilde paths in PathVariableReplacer.isCandidatePathValue()
  and ProjectsMetadataExporter.resolveExportFilename().
- hop-misc-git: Delegate CaseInsensitiveIgnores.replaceUserHome() to HopVfs.resolveHomeDirectory().
- Documentation: Update vfs.adoc, variables.adoc, and projects-environments.adoc with
  tilde home directory path usage and platform examples.
- Unit tests: Add test coverage in HopVfsTest and PathVariableReplacerTest.
@hansva
hansva merged commit 34c9db1 into apache:main Sep 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Environments with tilde in filename are created in unexpected place on *nix systems

2 participants