devonfw / ide

Tool to automate setup and update of development environment (esp. for Java projects).
Apache License 2.0
35 stars 101 forks source link

IntelliJ plugin installation not working #1104

Closed hohwille closed 1 year ago

hohwille commented 1 year ago

I have a project using devonfw-ide with intellij that needs specific plugins pre-installed for IntelliJ. Here I noticed that this feature got broken or never worked at all (see issue #453 and PR #600). In the logs I see this:

$ devon intellij
Updating intellij from version 2022.3.2 to version 2023.1...
Success: run command mkdir
Starting installation of intellij in version 2023.1 to /d/projects/test/software/intellij
Trying to download intellij-2023.1-U-windows.zip from https://download-cf.jetbrains.com/idea/ideaIU-2023.1.win.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1052M  100 1052M    0     0  11.1M      0  0:01:34  0:01:34 --:--:-- 11.2M
Download of intellij-2023.1-U-windows.zip from https://download-cf.jetbrains.com/idea/ideaIU-2023.1.win.zip succeeded.
Success: run command unzip
Successfully extracted archive intellij-2023.1-U-windows.zip to /d/projects/test/updates/extracted/intellij
Creating backup by moving existing /d/projects/test/software/intellij to /d/projects/test/updates/backups/23-04-14
Success: run command mv
Successfully installed intellij
The software intellij has been added. You need to rerun 'devon' command without arguments or restart your terminal to update your PATH so the newly installed software will be found.
{
  "name": "IntelliJ IDEA",
  "version": "2023.1",
  "buildNumber": "231.8109.175",
  "productCode": "IU",
  "dataDirectoryName": "IntelliJIdea2023.1",
Success: verify installation of intellij (head)
Trying to download pluginManager?action=download&id=EclipseCodeFormatter&build=IU-231.8109.175 from https://plugins.jetbrains.com/pluginManager?action=download&id=EclipseCodeFormatter&build=IU-231.8109.175
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 10.3M  100 10.3M    0     0  5572k      0  0:00:01  0:00:01 --:--:-- 7647k
Download of pluginManager?action=download&id=EclipseCodeFormatter&build=IU-231.8109.175 from https://plugins.jetbrains.com/pluginManager?action=download&id=EclipseCodeFormatter&build=IU-231.8109.175 succeeded.
cp: -r not specified; omitting directory '/c/Users/hohwille/Downloads/devonfw-ide/'
rm: cannot remove '/c/Users/hohwille/Downloads/devonfw-ide/': Is a directory
Trying to download pluginManager?action=download&id=org.mapstruct.intellij&build=IU-231.8109.175 from https://plugins.jetbrains.com/pluginManager?action=download&id=org.mapstruct.intellij&build=IU-231.8109.175
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  135k  100  135k    0     0   285k      0 --:--:-- --:--:-- --:--:--  285k
Download of pluginManager?action=download&id=org.mapstruct.intellij&build=IU-231.8109.175 from https://plugins.jetbrains.com/pluginManager?action=download&id=org.mapstruct.intellij&build=IU-231.8109.175 succeeded.
cp: -r not specified; omitting directory '/c/Users/hohwille/Downloads/devonfw-ide/'
rm: cannot remove '/c/Users/hohwille/Downloads/devonfw-ide/': Is a directory
Trying to download pluginManager?action=download&id=org.sonarlint.idea&build=IU-231.8109.175 from https://plugins.jetbrains.com/pluginManager?action=download&id=org.sonarlint.idea&build=IU-231.8109.175
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  223M  100  223M    0     0  8014k      0  0:00:28  0:00:28 --:--:-- 8583k
Download of pluginManager?action=download&id=org.sonarlint.idea&build=IU-231.8109.175 from https://plugins.jetbrains.com/pluginManager?action=download&id=org.sonarlint.idea&build=IU-231.8109.175 succeeded.
cp: -r not specified; omitting directory '/c/Users/hohwille/Downloads/devonfw-ide/'
rm: cannot remove '/c/Users/hohwille/Downloads/devonfw-ide/': Is a directory
Success: Configure workspace (java)
Your workspace main has been updated
launching IntelliJ...
command /d/projects/test/software/intellij/bin/idea64.exe

If you read carefully you can see that 3 plugins should have been installed and have been downloaded. However cp and rm commands failed all 3 times. I checked my Download directory and found such files with rather odd filenames like pluginManageraction=download&id=org.mapstruct.intellij&build=IU-231.8109.175. I guess that windows or the shell does have problems with the special characters in the file name... The according code can be found here: https://github.com/devonfw/ide/blob/b238ee1138b9319db138bf0b24b5d363475f5e98/scripts/src/main/resources/scripts/command/intellij#L84-L88

As you can see it already tries to avoid special characters like ? or / in the filename. However, it does not handle & or = further there is a non printable Unicode character in the filename. IMHO the entire approach to rely on the server side URL path filename is not sane. We already provide a constructed name as argument "intellij-plugin-${intellij_build}-${pluginId}" so why dont we just use this as filename as well?

hohwille commented 1 year ago

It seems the download filename actually is something like EclipseFormatter-23.1.223.000.0-Eclipse_2023-03.zip what I can see when I manually download the file in the browser. However, the curl command to get this filename is this one: https://github.com/devonfw/ide/blob/b238ee1138b9319db138bf0b24b5d363475f5e98/scripts/src/main/resources/scripts/command/intellij#L85

Maybe this once worked but to me it seems broken:

$ curl -sI https://plugins.jetbrains.com/pluginManager?action=download\&id=EclipseCodeFormatter\&build=IU-231.8109.175
HTTP/1.1 301 Moved Permanently
Content-Length: 0
Connection: keep-alive
Date: Fri, 14 Apr 2023 14:57:38 GMT
Location: https://plugins.jetbrains.com/files/6546/319098/EclipseFormatter-23.1.223.000.0-Eclipse_2023-03.zip?updateId=319098&pluginId=6546&family=INTELLIJ&code=IU&build=231.8109.175
X-Cache: Miss from cloudfront
Via: 1.1 8ad073ef904d92431b3428f3430707ae.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: DUS51-C1
X-Amz-Cf-Id: 7iZIav1z7Ra0lZ16_exCKN_LH_eUtdi7ouXoC8uR6AC8Sfy-MyJeig==

So to me it seems that the HTTP header is now Location with capital L while the code expects a lower case l. Typically all header names are Capitalized but if this ever worked before it is because this has changed. After all it is kind of pointless to perform this extra HTTP request just to get a filename. We can also use unzip to determine if the file is in ZIP format or not...