Updating Visual Studio Code on Macs for not admin User

Jacek_ADC
Contributor II

Hello there,

maybe someone has an idea for solving this issue. We have started to enroll MacBooks to employees without admin rights. We was using first the visual studio code installer from jamf mac apps. The problem with this, is that i cant add some configuratio (for example creating a symlink for this app) within the jamf mac app installer config.

So at the moment i am using a normal policy with a pkg for vscode. Everything until here is working fine. 

When an update is released for vscode, the user (without admin right) can't install it. The first window which pops up is for the helper tool (updater) for visual studio code

SCR-20250114-jogc.png

 So i was searching for a solution and found this page here, which explains this problem:

https://github.com/microsoft/vscode/issues/115805

I am able to do all this changes for the group and ownership for the logged in user but the problem still persist.

SCR-20250114-jomd.png

My script

#!/bin/bash

set -x

# Get the current user's home directory
loggedInUser=$(stat -f "%Su" /dev/console)
USER_HOME="/Users/$loggedInUser"

echo $USER_HOME
echo $loggedInUser

# Path to Visual Studio Code binary
VSCODE_BIN="/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"

# Target symlink location
TARGET_SYMLINK="/usr/local/bin/code"

####

# Check if the symlink already exists
if [ -L "$TARGET_SYMLINK" ]; then
	echo "Symlink already exists. Removing it first."
	sudo rm "$TARGET_SYMLINK"
fi

# Create the symlink
ln -snf "$VSCODE_BIN" "$TARGET_SYMLINK"
echo "Symlink created: $TARGET_SYMLINK -> $VSCODE_BIN"

# Verify symlink creation
if [ -L "$TARGET_SYMLINK" ]; then
	echo "Symlink created successfully."
else
	echo "Failed to create symlink."
fi


# create settings.json file for disabling updates
# Define the path to the settings.json file >>>> NEW TEST
SETTINGS_PATH="$USER_HOME/Library/Application Support/Code/User/settings.json"

# Ensure the directory exists
mkdir -p "$(dirname "$SETTINGS_PATH")"

# JSON key and value to add/update
KEY="update.showReleaseNotes"
VALUE="false"

# Check if the file exists; if not, create it with an empty JSON object
if [ ! -f "$SETTINGS_PATH" ]; then
    echo "{}" > "$SETTINGS_PATH"
fi

# Add or update the setting using jq
if command -v jq &> /dev/null; then
    jq --arg key "$KEY" --arg value "$VALUE" '.[$key] = $value' "$SETTINGS_PATH" > "${SETTINGS_PATH}.tmp" && mv "${SETTINGS_PATH}.tmp" "$SETTINGS_PATH"
    echo "Setting \"$KEY\": \"$VALUE\" added/updated in $SETTINGS_PATH"
else
    echo "jq is not installed. Please install jq to use this script."
    exit 1
fi

# Set owner and group to the logged-in user and 'staff' for the application in /Applications

open -a /Applications/Visual\ Studio\ Code.app



sleep 5

chown -R $loggedInUser:staff "/Applications/Visual Studio Code.app"

chown $loggedInUser:staff ~/Library/Caches/com.microsoft.VSCode.ShipIt

exit 0

I am using this script, please ignore the part with the settings.json because this is not my preferred target. I would let install the user the update when its available.

 

Maybe someone has a solution for this.

I know, that i can create the symlink after visual studio code is installed through jamf mac apps (in self service) with an smartgroup which is scoping the right policy after vscode installation was updated to jamf pro, but the issue here is, that the installation of an mac app via jamf pro is not always updated instantly to jamf pro.

 

 

2 REPLIES 2

howie_isaacks
Valued Contributor II

Check out Installomator.

https://github.com/Installomator/Installomator

Not only can it be used to run the initial install, but it can also be used for updating apps. It can alert users that an app needs to quit to be updated. I have used it a lot for updates and it is currently what I use to install several of our standard build apps. The latest version of the software is always installed. The documentation explains how you can use Installomator for updates.

Jacek_ADC
Contributor II

@howie_isaacks thank you for this, i am already using insallomator for some other apps an be using it "on an emergency basis" for the updates also for vscode. But this is not really what i want achieve for vscode updates.