Skip to content

Conversation

@rrama
Copy link
Contributor

@rrama rrama commented Aug 19, 2025

Description

Move initial environment setup to one place that runs in a Goroutine to not block, then wait on the env before scanning to prevent a race condition.
Fix a race condition where the LS settings Path was causing a cache of the PATH before the environment was fully set up, then later restoring to this old value.

Note: Splitting the reading of user shell env and reading project env files to different places was scrapped, so we're staying with LoadConfiguredEnvironment, but still adding calls to WaitForDefaultEnv beforehand.
Note: Environment snapshotting for each workspace before reading the env files was scrapped last minute, as I realised it would prevent parallel project scanning. Plus, the ordering of whether the IDE SDK paths are prepended before or after the env files are read is a bit random. This being said, it is no worse than it was before the changes (probably), I had just hoped to make it a lot better all at once.

Added an option to config.New() to allow tests to create a config without having to search all the directories for binaries.
Also, removed Config.Path() as it was only used by tests and os.Getenv("PATH") is more reliable.

Checklist

  • Tests added and all succeed
  • Regenerated mocks, etc. (make generate)
  • N/A
  • Linted (make lint-fix)
  • README.md updated, if user-facing
  • N/A
  • License file updated, if new 3rd-party dependency is introduced
  • N/A

ShawkyZ and others added 7 commits August 19, 2025 12:43
Snapshot the environment before scans (fetching of the project env files) and restore it after. This is so environment variables from one project don't mix into another.
Split reading user shell env and reading project env files to different places.
Close env ready channel instead of writing a message to it, so it can be checked in multiple routines.
Fix incorrect handling of JAVA_HOME introduced in the previous commit.
Instead rely on the config reference already in the test.
A previous commit made it check the incorrect config.
It was breaking test parallelaism and had a race condition as it was implemented in the wrong places.
@snyk-io
Copy link

snyk-io bot commented Aug 19, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

code/snyk check is complete. No issues have been found. (View Details)

Was searching the default binary search paths before, which is too slow.
Removed environment snapshotting and restoring code.
Make the settings path wait for the default env if the user has a custom PATH set.
Fix the race condition where it was caching the PATH prior to addDefaults finishing.
Revert the split of loading the shell and configuration files separately.
Set GAF to fix/IDE-1314_use-shell-paths
rrama added 4 commits August 22, 2025 10:32
Refactor the function to be clearer about setting PATH
Remove unnecessary SetCurrentConfig calls in 2 config tests.
Increase the timeout in `Test_handleUntrustedFolders_shouldTriggerTrustRequestAndScanAfterConfirmation`.
The GAF change would have made it be behind the user's SHELL's PATH.
Also allowed optimising `updatePathFromSettings` to not need to wait for the default env during initialisation.
Realised we can rely on the scan setting the very first value for us.
Update comments to use English (simplified).
Use latest GAF from fix/IDE-1314_use-shell-paths
Revert SDK logic back to version on main.
@rrama rrama removed the ⚠️ DONT MERGE Not ready to be merged yet label Aug 22, 2025
@rrama rrama merged commit 295ed22 into main Aug 22, 2025
18 checks passed
@rrama rrama deleted the fix/IDE-1314_redo-env branch August 22, 2025 13:10
@rrama rrama restored the fix/IDE-1314_redo-env branch September 3, 2025 15:36
@rrama rrama deleted the fix/IDE-1314_redo-env branch September 3, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants