Skip to content

fix: add default path for crossover on macOS #3728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 33 additions & 24 deletions src/backend/utils/compatibility_layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,33 +300,42 @@ export async function getCrossover(): Promise<Set<WineInstallation>> {
return crossover
}

const crossoverMacPath = new Set<string>()

// search for crossover installed on /Applications/CrossOver.app
const crossoverAppPath = '/Applications/CrossOver.app'
if (existsSync(crossoverAppPath)) {
crossoverMacPath.add(crossoverAppPath)
}

// search for crossover installed around the system
await execAsync(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested to see if it won't duplicate the entry on the wine list?

Copy link
Contributor Author

@WangEdward WangEdward May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it on my machine with Spotlight disabled; it has only one entry of crossover.

I cannot test for duplicates as I do not have Spotlight (mdfind) enabled.

However, since crossoverMacPath is a Set, it should ignore duplicate entries.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point.
I will try to test on a macOS this week just to be sure.

'mdfind kMDItemCFBundleIdentifier = "com.codeweavers.CrossOver"'
)
.then(async ({ stdout }) => {
stdout.split('\n').forEach((crossoverMacPath) => {
const infoFilePath = join(crossoverMacPath, 'Contents/Info.plist')
if (crossoverMacPath && existsSync(infoFilePath)) {
const info = plistParse(
readFileSync(infoFilePath, 'utf-8')
) as PlistObject
const version = info['CFBundleShortVersionString'] || ''
const crossoverWineBin = join(
crossoverMacPath,
'Contents/SharedSupport/CrossOver/bin/wine'
)
crossover.add({
bin: crossoverWineBin,
name: `CrossOver - ${version}`,
type: 'crossover',
...getWineExecs(crossoverWineBin)
})
}
})
})
.catch(() => {
logInfo('CrossOver not found', LogPrefix.GlobalConfig)
).then(async ({ stdout }) => {
stdout.split('\n').forEach((crossoverPath) => {
crossoverMacPath.add(crossoverPath)
})
})

crossoverMacPath.forEach((crossoverPath) => {
const infoFilePath = join(crossoverPath, 'Contents/Info.plist')
if (crossoverPath && existsSync(infoFilePath)) {
const info = plistParse(
readFileSync(infoFilePath, 'utf-8')
) as PlistObject
const version = info['CFBundleShortVersionString'] || ''
const crossoverWineBin = join(
crossoverPath,
'Contents/SharedSupport/CrossOver/bin/wine'
)
crossover.add({
bin: crossoverWineBin,
name: `CrossOver - ${version}`,
type: 'crossover',
...getWineExecs(crossoverWineBin)
})
}
})
return crossover
}

Expand Down
Loading