jeanp413 / open-remote-ssh

VSCode Remote Development: Open any folder on a remote machine using SSH.
MIT License
294 stars 40 forks source link

Version mismatch after update to VSCodium #106

Closed Dgwrigh58 closed 1 year ago

Dgwrigh58 commented 1 year ago

Hello, I am using open-remote-ssh and it works quite well. I have a script which is downloading the newest version of vscodium-server and placing it in artifactory. Open-remote-ssh is pointing towards artifactory so it can grab the correct version of vscodium-server. I was able to connect to my remote server just fine the first time. If there is an update to VSCodium and I try to remote into that same server then it will give me a version mismatch error. If I go and delete the .vscodium-server folder on the remote server then it will work again. I have not connected to this server in several days so I was hoping that it would overwrite/install the new version of vscodium-server.

jeanp413 commented 1 year ago

@Dgwrigh58 I assume you are using "remote.SSH.serverDownloadUrlTemplate" setting right? what's the value of it? For the extension to download the matching vscodium server version it needs to use these variables

  // - ${quality}: vscode server quality, e.g. stable or insiders
  // - ${version}: vscode server version, e.g. 1.69.0
  // - ${commit}: vscode server release commit
  // - ${arch}: vscode server arch, e.g. x64, armhf, arm64
  // - ${release}: release number, vscodium only https://github.com/VSCodium/vscodium/pull/1192
Dgwrigh58 commented 1 year ago

Yep I have a script which sets the

  if [ "$(jq -r '.name' "$dir/extension/package.json")" = "open-remote-ssh" ]; then
            jq '.contributes.configuration.properties["remote.SSH.serverDownloadUrlTemplate"].default = "https://private-url/artifactory/bin-stable/Microsoft/VSCodiumServer/vscodium-reh-${os}-${arch}-${version}.${release}.tar.gz"' "$dir/extension/package.json" > "$dir/extension/package.json.tmp" && mv "$dir/extension/package.json.tmp" "$dir/extension/package.json"
        fi

Also i just realized I was testing the Remote.SSH: Default extensions and added open-remote-ssh to that which was causing that error i posted.

I am still getting a version mismatch error however which is preventing me from remoting in. If i delete the .vscodium-server folder on the remote server then open-remote-ssh will go grab the vscodium-server version perfectly and create a ssh connection perfectly.

As a note, I am airgapped so I have to have the vscodium server locally on artifactory.

Dgwrigh58 commented 1 year ago

Thanks for responding so quickly Jean!

As more added context im using code-marketplace to host extensions for vscodium. I created a artifactory.sh file and with that created a new dockerifle for code-marketplace. I am doing a minor edit of your extension to auto edit the download url.


#!/bin/sh

extensions_dir="/opt/downloaded"
base_url="<private url>/artifactory/bin-stable/Microsoft/VSCodeExtensions"

# Create the extensions directory if it doesn't exist
mkdir -p "$extensions_dir"

/opt/code-marketplace server --address 0.0.0.0:80 --extensions-dir /extensions &

while true; do
    # Get a list of all the files in the repository
    files=$(wget --no-check-certificate -qO- "$base_url/?list&deep=1&listFolders=1" | sed 's/.*href="//' | sed 's/".*//')

    # Loop through each file and download it to the extensions directory
    for file in $files; do
        wget --no-check-certificate -P "$extensions_dir" "$base_url/$file"
    done

    # Unzip each vsix file, modify the PreRelease value and delete TargetPlatform in extension.vsixmanifest, remove dependencies from package.json, and build a new zip.
    for vsix_file in $(find "$extensions_dir" -name '*.vsix'); do
        dir="${vsix_file%.*}"
        new_vsix_file="$dir.modified.vsix"
        unzip -o "$vsix_file" -d "$dir"
        xmlstarlet ed --inplace -u "//*[local-name()='Property'][@Id='Microsoft.VisualStudio.Code.PreRelease']/@Value" -v "false" "$dir/extension.vsixmanifest"
        xmlstarlet ed --inplace -d "//*[local-name()='Identity']/@TargetPlatform" "$dir/extension.vsixmanifest"
        # Remove extensionPack from package.json
        jq 'del(.extensionDependencies, .extensionPack)' "$dir/extension/package.json" > "$dir/extension/package.json.tmp" && mv "$dir/extension/package.json.tmp" "$dir/extension/package.json"

        # If extension is open-remote-ssh, modify package.json
        if [ "$(jq -r '.name' "$dir/extension/package.json")" = "open-remote-ssh" ]; then
            jq '.contributes.configuration.properties["remote.SSH.serverDownloadUrlTemplate"].default = "https://<private url>/artifactory/bin-stable/Microsoft/VSCodiumServer/vscodium-reh-${os}-${arch}-${version}.${release}.tar.gz"' "$dir/extension/package.json" > "$dir/extension/package.json.tmp" && mv "$dir/extension/package.json.tmp" "$dir/extension/package.json"
        fi

        cd "$dir"
        zip -2 -r "$new_vsix_file" *
        cd -
        mv "$new_vsix_file" "$vsix_file"
        rm -r "$dir"
    done

    /opt/code-marketplace add /opt/downloaded --extensions-dir /extensions
    sleep 86400  # Sleep for 24 hours
done

I wanted to do some slight modification to extensions so they'd show up in vscodium in a more user-friendly format.

Dgwrigh58 commented 1 year ago

My version of vscodium: 1.81.0 release: 23216 My version of vscodium-server on artifactory: vscodium-reh-linux-x64-1.81.0.23216.tar.gz

Even if i hard code the url to be what's below, I will still get the version mismatch.

https://<private url>/artifactory/bin-stable/Microsoft/VSCodiumServer/vscodium-reh-linux-x64-1.81.0.23216.tar.gz

jeanp413 commented 1 year ago

Could you check the commit value in the product.json file of both vscodium and vscodium-server? they should be the same

Dgwrigh58 commented 1 year ago

I got onto the remote server and went into ~/.vscodium-server/bin and did an LS

i see 2 numbers which appear to be commit ID's ad2ce925243280c8cd1054a2b27734e2b2e839c5 ee0ba35e0f5ffb18669618446b41de0e99569167

I open vscodium locally and check the about for the commit ID and get

Version: 1.81.0 Release: 23216 Commit: ee0ba35e0f5ffb18669618446b41de0e99569167

i went into that folder ~/.vscodium-server/bin/ee0ba35e0f5ffb18669618446b41de0e99569167/product.json

inside of product.json I see these values which seem not right to me: "commit": "ad2ce925243280c8cd1054a2b27734e2b2e839c5", "date": "2023-07-28T18:29:39.253Z", "version": "1.80.2", "release": "23209"

Artifactory:

I went into artifactory and grabbed the vscodium server that im using as a source for the URL template. This should be vscodium-reh-linux-x64-1.81.0.23216.tar.gz. I checked the product.json and have these results in it: "commit": "ee0ba35e0f5ffb18669618446b41de0e99569167", "date": "2023-08-04T18:13:51.063Z", "version": "1.81.0", "release": "23216"

The commit is right on the remote server but for some reason the product.json is wrong?

I went and deleted the the entire folder: ~/.vscodium-server/bin/ee0ba35e0f5ffb18669618446b41de0e99569167 and after remoting in with open-remote-ssh is repoluated the same folder with the correct commit in the product.json:

"commit": "ee0ba35e0f5ffb18669618446b41de0e99569167", "date": "2023-08-04T18:13:51.063Z", "version": "1.81.0", "release": "23216"

Dgwrigh58 commented 1 year ago

I think I know what happened as i just recreated it. I believe I was messing around with the url template and had it hardcoded to the url for vscodium-reh-linux-x64-1.80.2.23209.tar.gz. VSCodium updated and tried to remote into the server but there was a version mismatch and it errored out.

I just hard coded the wrong version agan and it created the correct commit ID folder but the product.json inside was once again the wrong info:

"commit": "ad2ce925243280c8cd1054a2b27734e2b2e839c5", "date": "2023-07-28T18:29:39.253Z", "version": "1.80.2", "release": "23209"

So even though I had updated the Template URL to be dynamic, I had already made the mistake of connecting with it hardcoded and setting the product.json with the wrong info.

jeanp413 commented 1 year ago

So even though I had updated the Template URL to be dynamic, I had already made the mistake of connecting with it hardcoded and setting the product.json with the wrong info.

So it's working properly now, correct?