You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: "Create a Local Package Repository Using miniCRAN | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "03/30/2017"
4
+
ms.date: "09/29/2017"
5
5
ms.prod: "sql-server-2016"
6
6
ms.reviewer: ""
7
7
ms.suite: ""
@@ -15,106 +15,185 @@ author: "jeannt"
15
15
ms.author: "jeannt"
16
16
manager: "jhubbard"
17
17
---
18
-
# Create a Local Package Repository Using miniCRAN
19
-
This topic describes how you can create a local R package repository using the R package **miniCRAN**.
18
+
# Create a local package repository Using miniCRAN
20
19
21
-
Because [!INCLUDE[ssNoVersion_md](../../includes/ssnoversion-md.md)] instances typically are located on a server that does not have Internet connectivity, the standard method of installing R packages (the R command `install.packages()`) might not work, as the package installer cannot access CRAN or any other mirror sites.
20
+
There are two ways that you can prepare R packages for installation onto a server without internet access.
22
21
23
-
There are two options for installing packages from a local share or repository:
22
+
-[Use the miniCRAN package to create a single local repository](#bkmk_miniCRAN)
24
23
25
-
+ Use the miniCRAN package to create a local repository of the packages you need, then install from this repository. This topic describes the miniCRAN method.
24
+
The [miniCRAN](https://cran.r-project.org/web/packages/miniCRAN/index.html) creates an internally consistent repository consisting of selected packages from CRAN-like repositories. The user specifies a set of desired packages, and miniCRAN recursively reads the dependency tree for these packages, and downloads only the listed packages and their dependencies.
26
25
27
-
+ Download the packages you need, and their dependencies, as zip files, and save them in a local folder, and then copy that folder to the [!INCLUDE[ssNoVersion_md](../../includes/ssnoversion-md.md)] computer. For more information on the manual copy method, see [Install Additional Packages on SQL Server](../../advanced-analytics/r-services/install-additional-r-packages-on-sql-server.md).
26
+
You can then move this local repository to the server, and proceed to install the packages without using the internet.
28
27
28
+
-[Manually download and copy packages one by one](#bkmk_manual)
29
29
30
-
## Step 1. Install miniCRAN and download packages
30
+
This article describes how you can create an R package repository using both methods, with particualr emphasis on the **miniCRAN** package.
31
31
32
+
## Prepare packages using miniCRAN
32
33
33
-
1. Install the miniCRAN package on a computer that has Internet access.
34
+
The goal of creating a local package repository is to provide a single location that a server administrator or other users in the organization can use to install new R packages on a server that does not have internet access.
34
35
35
-
~~~~
36
-
# Install miniCRAN and igraph
36
+
The miniCRAN package for R was written by Andre de Vries to make it easier to create a consistent, managed set of R packages for an organization.
- For details, see [miniCRAN](https://cran.r-project.org/web/packages/miniCRAN/index.html)
44
41
45
-
# Define the local download location
46
-
local_repo <- "~/miniCRAN"
47
-
~~~~
42
+
- For a walkthrough of the repository creation process, see [How to install R packages on an off-line SQL Server 2016 instance](http://blog.revolutionanalytics.com/2016/05/minicran-sql-server.html)
48
43
49
-
2. Download or install the packages you need to this computer usng the following R script. This will create the folder structure that you need to copy the packages to the [!INCLUDE[ssNoVersion_md](../../includes/ssnoversion-md.md)] later.
50
44
51
-
~~~~
52
-
# List the packages to get. Do not specify dependencies.
There are many advantages to using miniCRAN to create the repository:
60
46
61
-
# List local packages
62
-
pdb <- as.data.frame(
63
-
pkgAvail(local_repo, type = "win.binary", Rversion = "3.2"),
64
-
stringsAsFactors = FALSE)
65
-
head(pdb)
66
-
pdb$Package
67
-
pdb[, c("Package", "Version", "License")]
68
-
~~~~
47
+
-**Security**: Many R users are accustomed to downloading and installing new R packages at will, from CRAN or one of its mirror sites. However, for security reasons, production servers running [!INCLUDE[ssNoVersion_md](file:///C:\includes\ssnoversion-md.md)] typically do not have internet connectivity.
69
48
49
+
-**Easier offline installation**: To install package to an offline server requires that you also download all package dependencies, Using miniCRAN makes it easier to get all dependencies in the correct format.
70
50
71
-
## Step 2. Copy the miniCRAN repository to the SQL Server computer
51
+
-**Improved version management**: In a multiuser environment, there are good reasons to avoid unrestricted installation of multiple package versions on the server.
72
52
73
-
Copy the miniCRAN repository to the R_SERVICES library on the [!INCLUDE[ssNoVersion_md](../../includes/ssnoversion-md.md)] instance.
53
+
### Step 1. Install the miniCRAN package
74
54
75
-
+ For SQL Server 2016, the default folder is `C:/Program Files/Microsoft SQL Server/MSSQL13.MSSQLSERVER/R_SERVICES/library1`.
76
-
+ For SQL Server 2017, the default folder is `C:/Program Files/Microsoft SQL Server/MSSQL14.MSSQLSERVER/R_SERVICES/library1`.
55
+
You begin by creating a miniCRAN repository to use as a source. You should create this repository on a computer that has internet access.
77
56
78
-
If you have installed R Services using a named instance, be sure to include the instance name in the path, to ensure that the libraries are installed to the correct instance. For example, if your named instance is RTEST02, the default path for the named instance would be:
## Step 3. Install the packages on SQL Server using the miniCRAN repository
64
+
### Step 2. Define a package source: a CRAN mirror, or an MRAN snapshot
84
65
85
-
On the [!INCLUDE[ssNoVersion_md](../../includes/ssnoversion-md.md)] computer, open an R command line or RGUI as administrator.
86
-
87
-
> [!TIP]
88
-
> You might have multiple R libraries on the computer; therefore, to ensure that packages are installed to the correct instance, use the copy of RGUI or RTerm that is installed with the specific instance where you want to install the packages.
89
-
90
-
When prompted to specify a repository, select the folder containing the files you just copied; that is, the local miniCRAN repository.
66
+
1.Specifyamirrorsitetouseingettingpackages.
91
67
92
-
~~~~
93
-
# Run this R code as administrator on the SQL Server computer
2.Indicatealocalfolderinwhichtostorethecollectedpackages.Youneedn't name the folder miniCRAN; it could be a more descriptive name like "GeneticsPackages" or "ClientRPackages1.0.2".
110
73
111
-
Verify that the packages were installed.
112
-
~~~~
113
-
installed.packages()
114
-
~~~~
74
+
Just be sure to create the folder in advance. An error is raised if the `local_repo` folder does not exist when you run the R code later.
115
75
76
+
```R
77
+
local_repo <- "~/miniCRAN"
78
+
```
116
79
80
+
> [!NOTE] The tilde expansion operator returns an environment variable, with results equivalent to `Sys.getenv("R_USER")`.
117
81
118
-
##Acknowledgements
82
+
### Step 3. Add packages to the repository
119
83
120
-
The source for this information is this article by Andre de Vries, who also developed the miniCRAN package. For details and a complete walkthrough, see [How to install R packages on an off-line SQL Server 2016 instance](http://blog.revolutionanalytics.com/2016/05/minicran-sql-server.html)
84
+
1. After miniCRAN is installed, create a list that specifies the additional packages you want to download.
85
+
86
+
Do not include dependencies; the **igraph** package used by miniCRAN generates the list of dependencies for you. For more information about how to use this graph, see [Using miniCRAN to identify package
From this information, the miniCRAN package creates the folder structure that you need to copy the packages to the [!INCLUDE[ssNoVersion_md](file:///C:\includes\ssnoversion-md.md)] later.
109
+
110
+
4. At this point you should have a folder containing the packages you needed, and any additional packages that were required.
111
+
112
+
You can run the following code to list the packages contained in the miniCRAN repository.
### Step 4. Use the repository to add R packages to the instance library
122
+
123
+
After you have created the repository and added the packages you need, you must move the package repository to the server computer, and ensure that the R packages are installed in the correct library for use from SQL Server.
124
+
125
+
Depending on the version of SQL Server, there are two options for adding new packages to the R library associated with the SQL Server instance:
126
+
127
+
- Install to the instance library using the miniCRAN repository and R tools.
128
+
129
+
- Upload packages to a SQL database and install packages on a per-database basis, using the CREATE EXTERNAL LIBRARY statement. See [Install additional R packages on SQL Server](install-additional-r-packages-on-sql-server.md).
130
+
131
+
The following procedure describes how to install the packages using R tools.
132
+
133
+
1. Copy the folder containing the miniCRAN repository, in its entirety, to the server where you will install the packages.
134
+
135
+
2. Open an R command prompt using the R tool associated with the instance.
136
+
137
+
- For SQL Server 2017, the default folder is `C:/Program Files/Microsoft SQL Server/MSSQL14.MSSQLSERVER/R_SERVICES/library`.
138
+
139
+
- For SQL Server 2016, the default folder is `C:/Program Files/Microsoft SQL Server/MSSQL13.MSSQLSERVER/R_SERVICES/library`.
140
+
141
+
- For a named instance, the default path would be something like: `<instance_path>.RTEST/R_SERVICES/library`.
142
+
143
+
- If you have installed SQL Server to a different drive, or made any other changes in the installation path, be sure to make those changes as well.
144
+
145
+
3. Get the path for the instance library (in case you'reinauserdirectory), andaddittothelistoflibrarypaths.
>However, theDBAcanalsouserolestogiveuserstheabilitytoinstalltheirownpackages.Formoreinformation, see [RpackagemanagementforSQLServer](r-package-management-for-sql-server-r-services.md).
0 commit comments