-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathtroubleshooting.Rmd
More file actions
325 lines (244 loc) · 11.4 KB
/
Copy pathtroubleshooting.Rmd
File metadata and controls
325 lines (244 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
---
title: "Troubleshooting"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Troubleshooting}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
## Troubleshooting
### Build Synapser
When You install Synapser, You may encounter a similar error:
```{console}
$ R CMD BUILD .
Execution halted
ERROR: configuration failed for package ‘synapser’
* removing ‘/private/var/folders/2n/xwh21m9s3sq_mhnkbc6n6z_c0000gn/T/RtmpZ47UPP/Rinstf55478c3f09/synapser’
```
For this error, You can try first remove $HOME\.virtualenvs then run the build command again.
### Build Synapser when creating vignettes
When you build synapser, you may encounter the following error:
```{console}
$ R CMD BUILD .
Error: processing vignette 'upload.Rmd' failed with diagnostics:
No credentials provided.
--- failed re-building ‘upload.Rmd’
```
First, create a file named `.synapseConfig` in your home directory. Then add the following lines to the file:
```{console}
[authentication]
authtoken = <authtoken>
```
Now, you should be able to build Synapser.
### Dependency Conflicts (rjson/reticulate)
If you encounter errors related to rjson version conflicts during installation, such as:
```
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace 'rjson' 0.2.23 is being loaded, but <= 0.2.21 is required
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'synapser'
```
This occurs when you have a newer version of rjson installed that is incompatible with synapser. **The best solution is to use the recommended installation method:**
**Recommended Solution:**
For the latest version:
```r
# Install remotes if not already installed
if (!require("remotes", quietly = TRUE)) {
install.packages("remotes")
}
# Install the latest version of synapser (this automatically handles dependency versions)
remotes::install_cran("synapser", repos = c("http://ran.synapse.org", "https://cloud.r-project.org"))
```
For a specific version:
```r
# Install remotes if not already installed
if (!require("remotes", quietly = TRUE)) {
install.packages("remotes")
}
# Install a specific version of synapser (e.g., version 2.1.1.259 - major.minor.patch.build)
remotes::install_version("synapser", version = "X.Y.Z.AAA", repos = c("http://ran.synapse.org", "https://cloud.r-project.org"))
```
**Manual Resolution (if you prefer to manage dependencies yourself):**
1. **Remove the conflicting package:**
```r
remove.packages("rjson")
```
2. **Install the compatible version using remotes:**
```r
if (!require("remotes", quietly = TRUE)) {
install.packages("remotes")
}
remotes::install_version("rjson", "0.2.21")
```
3. **Also ensure you have the correct reticulate version:**
```r
remotes::install_version("reticulate", "1.28")
```
4. **Re-install synapser:**
```r
install.packages("synapser", repos=c("http://ran.synapse.org", "https://cloud.r-project.org"))
```
### Python Version Compatibility
Synapser is only compatible with Python versions 3.9 to 3.11. If you're using Python 3.12 or later, you may encounter installation or runtime errors. We recommend using Python 3.10 for optimal compatibility.
To check your Python version in R:
```r
reticulate::py_config()
```
### R Version Compatibility
**Important**: synapser versions 2.1.0+ require R versions 4.1.3 ≤ R < 4.5. If you are using R ≥ 4.5, the installation will automatically fall back to synapser 2.0.0 instead of the latest version.
#### Troubleshooting R Version Issues:
**Check your R version:**
```r
R.version.string
```
**If installation selects 2.0.0 when you expect 2.1.1:**
- Verify your R version is between 4.1.3 and 4.5.2
- Check that your reticulate version is ≤ 1.28 (required for synapser 2.1.x)
- Consider using the recommended installation method with version specification
**Linux (Ubuntu/Debian):**
```bash
# Remove current R version
sudo apt remove r-base r-base-core r-base-dev
# Add CRAN repository for specific R version
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
# Install R 4.4
sudo apt install r-base=4.4.2-1cran1.2004.0 r-base-core=4.4.2-1cran1.2004.0
```
**Linux (Amazon Linux/RHEL/CentOS):**
```bash
# Remove current R version
sudo dnf remove R R-core R-devel
# Option 1: Install from source (recommended for version control)
sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y gcc-gfortran readline-devel libX11-devel libXt-devel \
zlib-devel bzip2-devel xz-devel pcre2-devel curl-devel
# Download and compile R 4.4.2
cd /tmp
wget https://cran.r-project.org/src/base/R-4/R-4.4.2.tar.gz
tar -xzf R-4.4.2.tar.gz
cd R-4.4.2
./configure --enable-R-shlib --with-blas --with-lapack
make
sudo make install
# Fix PATH if older R version is still being used
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
```
**Verify Installation:**
```r
R.version.string
```
**Troubleshooting Amazon Linux R Installation:**
If `which R` still shows an old R version after compilation:
```bash
# Check current R location
which R
# If it shows /usr/local/R-4.5.1/bin/R instead of /usr/local/bin/R:
export PATH="/usr/local/bin:$PATH"
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
```
### Using Synapser with reticulate
Synapser is compatible with [reticulate](https://rstudio.github.io/reticulate/) and the two packages can be used together in the same R session.
If you are getting this kind error:
```
synStore(tmp2)
Error in value[[3L]](cond) : 'concreteType'
```
As of synapser v2.0.0, it is still only compatible with reticulate v1.28 due to a miscellaneous update in [reticulate v1.29](https://rstudio.github.io/reticulate/news/index.html#misc-1-29). Specifically, `py_to_r()` now succeeds when converting subtypes of the built-in Python types (e.g. list, dict, str). This change, while beneficial for general use, breaks synapser's internal type conversion mechanisms.
**Why this limitation exists:** Synapser relies on specific behavior in reticulate's type conversion system to properly handle Synapse objects and their metadata. The changes in reticulate v1.29+ alter how Python objects are converted back to R, causing compatibility issues with synapser's architecture.
To install the compatible version:
```
remotes::install_version("reticulate", "1.28")
```
**Alternative approach:** If you need to use a newer version of reticulate for other projects, you can use the [Synapse Python client](https://python-docs.synapse.org/build/html/index.html) directly through reticulate instead of synapser.
### Type Conversions
The core of the Synapser library is the [python client](https://python-docs.synapse.org/). [Reticulate](https://rstudio.github.io/reticulate/) is used to translate R to Python and back.
These are the documented conversions from R to Python: [Reticulate Type Conversions](https://rstudio.github.io/reticulate/articles/calling_python.html#type-conversions)
`NA` values in R do not have a direct equivalent in Python. This has been a topic of great discussion. Synapser is not trying to solve this. `NA` values in R are handled by Reticulate per the implementation defined in Reticulate.
When working with R and Reticulate, NA values in types tables are converted by Reticulate depending on the data type.
For numeric data types, NA values are converted to the corresponding R value `NA_real_`.
For integer data types, NA values are converted to `NA_integer_`.
For logical data types, NA values are converted to `NA_logical_`.
For character data types, NA values are converted to `NA_character_`.
In addition, Reticulate also converts any values that cannot be coerced to the specified data type to `NA_character_`.
Reticulate performs these conversions automatically.
When Reticulate converts R objects to Python objects, the NA values in R types tables are converted to Python's `None`.
R's `NA` is a logical constant of length 1 which is used to represent the absence of a value. In Python, the equivalent of `NA` is `None`, which is a special constant used to indicate the absence of a value.
Reticulate automatically converts `NA` values in R types tables to `None` when converting R objects to Python. This ensures that the data types and values remain consistent between the two languages.
Examples:
* Reticulate converts logical `NA`s to Python `True`, which convert back to `TRUE` in R
```{r collapse = TRUE}
na_logical = NA
class(na_logical)
na_py <- reticulate::r_to_py(na_logical)
na_py
na_r <- reticulate::py_to_r(na_py)
na_r
```
```{r collapse = TRUE}
na_logical = c(T, F, NA)
class(na_logical)
na_py <- reticulate::r_to_py(na_logical)
na_py
na_r <- reticulate::py_to_r(na_py)
na_r
```
* Reticulate converts character `NA`s to Python strings, which convert back to characters in R
```{r collapse = TRUE}
na_char = c("T", "F", NA)
class(na_char)
na_py <- reticulate::r_to_py(na_char)
na_py
na_r <- reticulate::py_to_r(na_py)
na_r
```
* Reticulate converts numeric `NA`s to Python `np.nan`, which convert back to `NA` in R
```{r collapse = TRUE}
na_num = c(1538006762583, 1538006762584, NA)
class(na_num)
na_py <- reticulate::r_to_py(na_num)
na_py
na_r <- reticulate::py_to_r(na_py)
na_r
```
### Poisoned cache and endswith error
Starting with the [Synapse Python client version 4.2.0](https://python-docs.synapse.org/en/stable/news/#420-2024-04-17),
a change to how the Synapse Cache writes entries was introduced. The purpose of the change
was to more accurately track when a file was last modified, and what the MD5 checksum of the file was
at that point in time. Prior to this change the Synapse cache was a simple key-value store,
however, with the new change, the cache is now a dictionary of dictionaries.
If you find that you receive the following error when trying to use `synGet`:
```r
> synapser::synGet("syn12345")
Error in value[[3L]](cond) : 'dict' object has no attribute 'endswith'
```
You may have a "poisoned" cache. This can happen if you, or someone using the file system
where your Synapse cache is stored, has ran the newer Synapse Python client - while
you are still using the older version of Synapser/Python Client.
To resolve this issue, you can either:
1. **Delete the Synapse cache directory**: This will force Synapser to re-download all files from Synapse
and rebuild the cache. By default the cache is stored in `~/.synapseCache`.
**Note:** The following suggested commands have the potential to delete many files, so please
ensure you have backups of any important data before running them. The cache directory is typically
used to store temporary files and metadata. Deleting this data will only affect
your local machine - It will not affect any data that is stored in Synapse. This will
require you to re-download files from Synapse.
The exact commands will depend on your operating system, but here are some examples:
- **Linux/macOS**:
```bash
rm -rf ~/.synapseCache
```
- **Windows**:
```powershell
Remove-Item -Recurse -Force $HOME\.synapseCache
```
2. **Upgrade to the latest version of Synapser**: This will ensure that you are using
the latest version of the Synapse Python client, which is compatible with the new cache format.
```r
remotes::install_cran("synapser", repos = c("http://ran.synapse.org", "https://cloud.r-project.org"))
```