@@ -65,13 +65,13 @@ type LaunchContext struct {
65
65
backendVersion * version.Version
66
66
wsInfo * supervisor.WorkspaceInfoResponse
67
67
68
- vmOptionsFile string
69
- projectDir string
70
- configDir string
71
- systemDir string
72
- projectConfigDir string
73
- projectContextDir string
74
- riderSolutionFile string
68
+ vmOptionsFile string
69
+ platformPropertiesFile string
70
+ projectDir string
71
+ configDir string
72
+ systemDir string
73
+ projectContextDir string
74
+ riderSolutionFile string
75
75
76
76
env []string
77
77
}
@@ -462,34 +462,36 @@ func launch(launchCtx *LaunchContext) {
462
462
}
463
463
464
464
launchCtx .projectDir = projectDir
465
- launchCtx .configDir = fmt .Sprintf ("/workspace/.config/JetBrains%s" , launchCtx .qualifier )
466
- launchCtx .systemDir = fmt .Sprintf ("/workspace/.cache/JetBrains%s" , launchCtx .qualifier )
465
+ launchCtx .configDir = fmt .Sprintf ("/workspace/.config/JetBrains%s/RemoteDev-%s " , launchCtx .qualifier , launchCtx . info . ProductCode )
466
+ launchCtx .systemDir = fmt .Sprintf ("/workspace/.cache/JetBrains%s/RemoteDev-%s " , launchCtx .qualifier , launchCtx . info . ProductCode )
467
467
launchCtx .riderSolutionFile = riderSolutionFile
468
468
launchCtx .projectContextDir = resolveProjectContextDir (launchCtx )
469
- launchCtx .projectConfigDir = fmt .Sprintf ("%s/RemoteDev-%s/%s" , launchCtx .configDir , launchCtx .info .ProductCode , strings .ReplaceAll (launchCtx .projectContextDir , "/" , "_" ))
470
469
471
- alreadySync , err := syncInitialContent (launchCtx , Options )
470
+ launchCtx .platformPropertiesFile = launchCtx .backendDir + "/bin/idea.properties"
471
+ _ , err = configurePlatformProperties (launchCtx .platformPropertiesFile , launchCtx .configDir , launchCtx .systemDir )
472
+ if err != nil {
473
+ log .WithError (err ).Error ("failed to update platform properties file" )
474
+ }
475
+
476
+ _ , err = syncInitialContent (launchCtx , Options )
472
477
if err != nil {
473
478
log .WithError (err ).Error ("failed to sync initial options" )
474
479
}
475
480
476
- launchCtx .env = resolveLaunchContextEnv (launchCtx . configDir , launchCtx . systemDir , ! alreadySync )
481
+ launchCtx .env = resolveLaunchContextEnv ()
477
482
478
483
_ , err = syncInitialContent (launchCtx , Plugins )
479
484
if err != nil {
480
485
log .WithError (err ).Error ("failed to sync initial plugins" )
481
486
}
482
487
483
488
// install project plugins
484
- version_2022_1 , _ := version .NewVersion ("2022.1" )
485
- if version_2022_1 .LessThanOrEqual (launchCtx .backendVersion ) {
486
- err = installPlugins (gitpodConfig , launchCtx )
487
- installPluginsCost := time .Now ().Local ().Sub (launchCtx .startTime ).Milliseconds ()
488
- if err != nil {
489
- log .WithError (err ).WithField ("cost" , installPluginsCost ).Error ("installing repo plugins: done" )
490
- } else {
491
- log .WithField ("cost" , installPluginsCost ).Info ("installing repo plugins: done" )
492
- }
489
+ err = installPlugins (gitpodConfig , launchCtx )
490
+ installPluginsCost := time .Now ().Local ().Sub (launchCtx .startTime ).Milliseconds ()
491
+ if err != nil {
492
+ log .WithError (err ).WithField ("cost" , installPluginsCost ).Error ("installing repo plugins: done" )
493
+ } else {
494
+ log .WithField ("cost" , installPluginsCost ).Info ("installing repo plugins: done" )
493
495
}
494
496
495
497
// install gitpod plugin
@@ -586,7 +588,7 @@ func resolveUserEnvs() (userEnvs []string, err error) {
586
588
return
587
589
}
588
590
589
- func resolveLaunchContextEnv (configDir string , systemDir string , enableNewUI bool ) []string {
591
+ func resolveLaunchContextEnv () []string {
590
592
var launchCtxEnv []string
591
593
userEnvs , err := resolveUserEnvs ()
592
594
if err == nil {
@@ -596,21 +598,14 @@ func resolveLaunchContextEnv(configDir string, systemDir string, enableNewUI boo
596
598
launchCtxEnv = os .Environ ()
597
599
}
598
600
599
- // Set default config and system directories under /workspace to preserve between restarts
600
- launchCtxEnv = append (launchCtxEnv ,
601
- // Set default config and system directories under /workspace to preserve between restarts
602
- fmt .Sprintf ("IJ_HOST_CONFIG_BASE_DIR=%s" , configDir ),
603
- fmt .Sprintf ("IJ_HOST_SYSTEM_BASE_DIR=%s" , systemDir ),
604
- )
605
-
606
601
// instead put them into /ide-desktop/${alias}${qualifier}/backend/bin/idea64.vmoptions
607
602
// otherwise JB will complain to a user on each startup
608
603
// by default remote dev already set -Xmx2048m, see /ide-desktop/${alias}${qualifier}/backend/plugins/remote-dev-server/bin/launcher.sh
609
604
launchCtxEnv = append (launchCtxEnv , "JAVA_TOOL_OPTIONS=" )
610
605
611
- if enableNewUI {
612
- launchCtxEnv = append ( launchCtxEnv , "REMOTE_DEV_NEW_UI_ENABLED=1" )
613
- }
606
+ // Force it to be disabled as we update platform properties file already
607
+ // TODO: Some ides have it enabled by default still, check pycharm and remove next release
608
+ launchCtxEnv = append ( launchCtxEnv , "REMOTE_DEV_LEGACY_PER_PROJECT_CONFIGS=0" )
614
609
615
610
log .WithField ("env" , strings .Join (launchCtxEnv , "\n " )).Info ("resolved launch env" )
616
611
@@ -637,6 +632,52 @@ func handleSignal() {
637
632
log .Info ("asked IDE to terminate" )
638
633
}
639
634
635
+ func configurePlatformProperties (platformOptionsPath string , configDir string , systemDir string ) (bool , error ) {
636
+ buffer , err := os .ReadFile (platformOptionsPath )
637
+ if err != nil {
638
+ return false , err
639
+ }
640
+
641
+ content := string (buffer )
642
+
643
+ updated , content := updatePlatformProperties (content , configDir , systemDir )
644
+
645
+ if updated {
646
+ return true , os .WriteFile (platformOptionsPath , []byte (content ), 0 )
647
+ }
648
+
649
+ return false , nil
650
+ }
651
+
652
+ func updatePlatformProperties (content string , configDir string , systemDir string ) (bool , string ) {
653
+ lines := strings .Split (content , "\n " )
654
+ configMap := make (map [string ]bool )
655
+ for _ , v := range lines {
656
+ v = strings .TrimSpace (v )
657
+ if v != "" && ! strings .HasPrefix (v , "#" ) {
658
+ key , _ , found := strings .Cut (v , "=" )
659
+ if found {
660
+ configMap [key ] = true
661
+ }
662
+ }
663
+ }
664
+
665
+ updated := false
666
+
667
+ if _ , found := configMap ["idea.config.path" ]; ! found {
668
+ updated = true
669
+ content = strings .Join ([]string {
670
+ content ,
671
+ fmt .Sprintf ("idea.config.path=%s" , configDir ),
672
+ fmt .Sprintf ("idea.plugins.path=%s" , configDir + "/plugins" ),
673
+ fmt .Sprintf ("idea.system.path=%s" , systemDir ),
674
+ fmt .Sprintf ("idea.log.path=%s" , systemDir + "/log" ),
675
+ }, "\n " )
676
+ }
677
+
678
+ return updated , content
679
+ }
680
+
640
681
func configureVMOptions (config * gitpod.GitpodConfig , alias string , vmOptionsPath string ) error {
641
682
options , err := readVMOptions (vmOptionsPath )
642
683
if err != nil {
@@ -647,7 +688,7 @@ func configureVMOptions(config *gitpod.GitpodConfig, alias string, vmOptionsPath
647
688
}
648
689
649
690
func readVMOptions (vmOptionsPath string ) ([]string , error ) {
650
- content , err := ioutil .ReadFile (vmOptionsPath )
691
+ content , err := os .ReadFile (vmOptionsPath )
651
692
if err != nil {
652
693
return nil , err
653
694
}
@@ -657,7 +698,7 @@ func readVMOptions(vmOptionsPath string) ([]string, error) {
657
698
func writeVMOptions (vmOptionsPath string , vmoptions []string ) error {
658
699
// vmoptions file should end with a newline
659
700
content := strings .Join (vmoptions , "\n " ) + "\n "
660
- return ioutil .WriteFile (vmOptionsPath , []byte (content ), 0 )
701
+ return os .WriteFile (vmOptionsPath , []byte (content ), 0 )
661
702
}
662
703
663
704
// deduplicateVMOption append new VMOptions onto old VMOptions and remove any duplicated leftmost options
@@ -844,7 +885,7 @@ func syncPlugin(file fs.FileInfo, srcDir, destDir string) error {
844
885
}
845
886
846
887
func ensureInitialSyncDest (launchCtx * LaunchContext , target SyncTarget ) (string , error , bool ) {
847
- targetDestDir := launchCtx .projectConfigDir
888
+ targetDestDir := launchCtx .configDir
848
889
if target == Plugins {
849
890
targetDestDir = launchCtx .backendDir
850
891
}
@@ -964,7 +1005,7 @@ func installPlugins(config *gitpod.GitpodConfig, launchCtx *LaunchContext) error
964
1005
installErr := cmd .Run ()
965
1006
966
1007
// delete alien_plugins.txt to suppress 3rd-party plugins consent on startup to workaround backend startup freeze
967
- err = os .Remove (launchCtx .projectConfigDir + "/alien_plugins.txt" )
1008
+ err = os .Remove (launchCtx .configDir + "/alien_plugins.txt" )
968
1009
if err != nil && ! os .IsNotExist (err ) && ! strings .Contains (err .Error (), "no such file or directory" ) {
969
1010
log .WithError (err ).Error ("failed to suppress 3rd-party plugins consent" )
970
1011
}
0 commit comments