Skip to content

Commit 8cc74dd

Browse files
author
Bryan Kneis
authored
Allow manual deb file to be installed (#1831)
* Allow manual deb file to be installed * Return if rstudio server is already installed
1 parent f4d7cd6 commit 8cc74dd

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

cmd/agent/container/setup.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,10 @@ func (cmd *SetupContainerCmd) installIDE(setupInfo *config.Result, ide *provider
460460
case string(config2.IDEJupyterNotebook):
461461
return jupyter.NewJupyterNotebookServer(setupInfo.SubstitutionContext.ContainerWorkspaceFolder, config.GetRemoteUser(setupInfo), ide.Options, log).Install()
462462
case string(config2.IDERStudio):
463-
return rstudio.NewRStudioServer(setupInfo.SubstitutionContext.ContainerWorkspaceFolder, config.GetRemoteUser(setupInfo), ide.Options, log).Install()
463+
err := rstudio.NewRStudioServer(setupInfo.SubstitutionContext.ContainerWorkspaceFolder, config.GetRemoteUser(setupInfo), ide.Options, log).Install()
464+
if err != nil {
465+
log.Errorf("could not install rstudio with error: %w", err)
466+
}
464467
}
465468

466469
return nil

pkg/ide/rstudio/rstudio.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,31 +81,36 @@ type RStudioServer struct {
8181
var codenameRegEx = regexp.MustCompile(`\nUBUNTU_CODENAME=(.*)\n`)
8282

8383
func (o *RStudioServer) Install() error {
84+
debPath := filepath.Join(filepath.ToSlash(downloadFolder), "rstudio-server.deb")
85+
// R has to be installed
86+
if !command.ExistsForUser("R", o.userName) {
87+
return fmt.Errorf("R has to be available in image to use RStudio") //nolint:all
88+
}
89+
8490
// Skip if already installed
8591
if command.ExistsForUser("rstudio-server", o.userName) {
8692
o.log.Debug("RStudio is already installed, skipping installation")
8793
return nil
8894
}
89-
90-
// R has to be installed
91-
if !command.ExistsForUser("R", o.userName) {
92-
return fmt.Errorf("R has to be available in image to use RStudio") //nolint:all
93-
}
9495
o.log.Info("Installing RStudio")
9596

9697
err := ensureGdebi(o.log)
9798
if err != nil {
9899
return err
99100
}
100101

101-
codename, err := getDistroCodename(o.log)
102-
if err != nil {
103-
return nil
104-
}
102+
// Check if local file exists
103+
if _, err := os.Stat(debPath); os.IsNotExist(err) {
104+
o.log.Info("Rstudio deb not file, downloading ...")
105+
codename, err := getDistroCodename(o.log)
106+
if err != nil {
107+
return err
108+
}
105109

106-
debPath, err := downloadRStudioDeb(codename, o.log)
107-
if err != nil {
108-
return nil
110+
debPath, err = downloadRStudioDeb(codename, o.log)
111+
if err != nil {
112+
return err
113+
}
109114
}
110115

111116
err = installDeb(debPath, o.log)

0 commit comments

Comments
 (0)