Repository navigation
fix: a downloaded archive whose root entry is ./ gives its language server a command without /./ - #2192
Conversation
…erver a command without /./
The extraction took the first segment of each entry as the top level of the
archive, so an archive whose root entry is ./, as the .tar.gz of cpp_ls, had
the single root folder ".". The download then appended it to ${output.dir},
which gave cpp_ls the command "$USER_HOME$/.lsp4ij/lsp/cpp_ls/./cpp_ls".
The top level of an entry is now its first segment that isn't "." or empty,
and the entry ./ has none. So for such an archive:
- ${output.dir} and the command have no /./: cpp_ls gets
"$USER_HOME$/.lsp4ij/lsp/cpp_ls/cpp_ls".
- With stripRootFolder, the install no longer fails with "Invalid argument"
while moving the folder "." into itself.
- An archive of one folder under ./, as ./server-1.0/bin/server, adds the
name of that folder, as one without ./ does, instead of failing to find its
output.file.name in "<dir>/.".
Fixes redhat-developer#2139
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2192 +/- ##
==========================================
+ Coverage 54.23% 54.25% +0.01%
==========================================
Files 832 832
Lines 35334 35334
Branches 7286 7286
==========================================
+ Hits 19163 19169 +6
+ Misses 13348 13342 -6
Partials 2823 2823 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action performed
|
Fixes #2139
What
An archive whose root entry is
./, as the.tar.gzassets of cpp_ls are (./and./cpp_ls), gave its languageserver a command with
/./:"$USER_HOME$/.lsp4ij/lsp/cpp_ls/./cpp_ls", with${output.dir}=…/cpp_ls/.. The serverstarted, but the path showed in the settings and in the LSP console, and
replaceTemplateCommandcompares a command aswritten.
While testing it, two failures of the same cause showed up:
stripRootFolder, the installation failed with "Invalid argument", moving the folder.into itself;./, such as./server-1.0/bin/server, failed to find itsoutput.file.namein<dir>/..Cause
DownloadUtils.decompresstook the first path segment of each entry as the archive's top level. For./and./cpp_ls, that made.the single root folder, whichDownloadTaskthen appended to the output dir, or tried tostrip.
Change
In
DownloadUtils.decompress, the top level of an entry is its first segment that isn't.or empty. The entry./has none.
cpp_ls, which isn't a folder, so nothing is appended../: that folder is appended, as for one without./.Normalizing in
DownloadTaskinstead, as the issue suggested, wouldn't work:<dir>/.normalized is<dir>, whose namecpp_lswould then be appended, giving…/cpp_ls/cpp_ls/cpp_ls...can't reach this code: IntelliJ'sDecompressorrejects entries with.../is already stripped byDecompressor.Entry.I checked the real assets with
gh release download.cpp_ls-darwin-arm64.tar.gzhas exactly./and./cpp_ls.cpp_ls-win32-x64.ziphas onlycpp_ls.exe, and was never affected.Tests
New
DownloadTaskArchiveRootTest(8 tests). It runs the bundled cpp_lsinstaller.json, with its download replaced bya
file:URL to an archive built in a temp folder: a.tar.gzwritten with commons-compress, or a.zip. Each testchecks
${output.dir}, the exact command, and where the server file ends up../root:.tar.gzand.zip, each with and withoutstripRootFolder;cpp_ls-1.0/…), which still appends its name;./,.tar.gzand.zip, which appendscpp_ls-1.0;stripRootFolderwith one folder under./, which strips it.Without the fix, 7 of the 8 fail; only the plain single-root folder passes. With it, all pass, also headless. The
installation.*tests pass on IC 2024.2, 2025.3 and IU 2026.3: 194 each, with 0 failures or skipped.Behaviour change
./(cpp_ls on macOS and Linux) gives the command"$USER_HOME$/.lsp4ij/lsp/cpp_ls/./cpp_ls". WithstripRootFolder, the installation fails with "Invalid argument". An archive of one folder under./fails to find itsoutput.file.name"$USER_HOME$/.lsp4ij/lsp/cpp_ls/cpp_ls".stripRootFolderworks, and an archive of one folder under./appends that folder's name, as one without./does