Coder Social home page Coder Social logo

eddelbuettel / rcpptoml Goto Github PK

View Code? Open in Web Editor NEW
33.0 5.0 8.0 615 KB

Rcpp Bindings to C++ parser for TOML files

License: GNU General Public License v2.0

Shell 0.01% C++ 95.15% R 3.46% C 1.39%
r c-plus-plus-11 cran r-package toml toml-parser toml-parsing

rcpptoml's Issues

revive?

Hi Dirk,

I was wondering how difficult it would be to revive this, along with windows support, given the updates to the window toolchain in 3.3+

Is that possible?

I attempted to muck around however C++ is completely out of my league.

Boolean Arrays return Lists

Sorry to pile on today.

Here's my TOML file:

title = "TOML Testing Example"

[testing]

bool = true
bool_vec = [true, false, true]

string = "Test String"
string_vec = ["All", "work and no", "play"]

num = 1
num_vec = [1, 2, 3, 4]

And my R code:

> library(RcppTOML)
> toml <- parseTOML("testing.toml")
> str(toml)

List of 2
 $ testing:List of 6
  ..$ bool      : logi TRUE
  ..$ bool_vec  :List of 3
  .. ..$ : logi TRUE
  .. ..$ : logi FALSE
  .. ..$ : logi TRUE
  ..$ num       : int 1
  ..$ num_vec   : int [1:4] 1 2 3 4
  ..$ string    : chr "Test String"
  ..$ string_vec: chr [1:3] "All" "work and no" "play"
 $ title  : chr "TOML Testing Example"
 - attr(*, "class")= chr [1:2] "toml" "list"
 - attr(*, "file")= chr "testing.toml"

I don't think that bool_vec should be structured as a list, right?

Install problems with RcppTOML - headers not found

Hello,

we face problems with
upgrading (0.1.3-0.1.7)/installing (0.1.7) RcppTOML in this environment

  1. R4.2.1,
  2. g++ (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3) [devtools-8],
  3. make --version GNU Make 4.2.1
  4. R-Makevars: g++17.

Compilation of RcppTOML selects "g++ -std=gnu++11".

This exact same environment/R implementation
allowed installing RFast (2.0.6) in the previous step
with no issues,
which has "SystemRequirements: C++17".

Environment:

# gcc --version
gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
# g++ --version
g++ (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
# make --version
GNU Make 4.2.1


# $(gcc -print-prog-name=cc1) --help | grep std
  -Wintrinsics-std            		[disabled]
  -std=extra-legacy           		
  -std=f2003                  		
  -std=f2008                  		
  -std=f2008ts                		
  -std=f2018                  		
  -std=f95                    		
  -std=gnu                    		
  -std=legacy                 		
  -fobjc-std=objc1            		[disabled]
  -nostdinc                   		
  -nostdinc++                 		
  -nostdlib                   		
  -std=c++03                  		
  -std=c++11                  		
  -std=c++14                  		
  -std=c++17                  		
  -std=c++2a                  		
  -std=c++98                  		
  -std=c11                    		
  -std=c17                    		
  -std=c18                    		
  -std=c1x                    		
  -std=c89                    		
  -std=c90                    		
  -std=c99                    		
  -std=c9x                    		
  -std=gnu++03                		
  -std=gnu++11                		
  -std=gnu++14                		
  -std=gnu++17                		
  -std=gnu++2a                		
  -std=gnu++98                		
  -std=gnu11                  		
  -std=gnu17                  		
  -std=gnu18                  		
  -std=gnu1x                  		
  -std=gnu89                  		
  -std=gnu90                  		
  -std=gnu99                  		
  -std=gnu9x                  		
  -std=iso9899:1990           		
  -std=iso9899:199409         		
  -std=iso9899:1999           		
  -std=iso9899:199x           		
  -std=iso9899:2011           		
  -std=iso9899:2017           		
  -std=iso9899:2018           		
  -fstdarg-opt                		[enabled]
# R
R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
# /usr/include/c++
total 24
drwxr-xr-x.  3 root root    45 Jun 28 16:04 .
drwxr-xr-x. 92 root root 12288 Feb  7 11:52 ..
drwxr-xr-x. 12 root root  4096 Jul 12  2021 4.8.2
lrwxrwxrwx.  1 root root     5 Jul 12  2021 4.8.5 -> 4.8.2
lrwxrwxrwx.  1 root root    43 Jun 28 16:04 8.3.1 -> /opt/rh/devtoolset-8/root/usr/include/c++/8
# echo $LD_LIBRARY_PATH
/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:/opt/rh/devtoolset-8/root/usr/lib64/dyninst:/opt/rh/devtoolset-8/root/usr/lib/dyninst:/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib

Failure report:

> update.packages()
RcppTOML :
 Version 0.1.3 installed in /opt/R/4.2.1/lib/R/library 
 Version 0.1.7 available at https://ftp.fau.de/cran
Update? (Yes/no/cancel) y
trying URL 'https://ftp.fau.de/cran/src/contrib/RcppTOML_0.1.7.tar.gz'
Content type 'application/x-gzip' length 42551 bytes (41 KB)
==================================================
downloaded 41 KB

* installing *source* package ‘RcppTOML’ ...
** package ‘RcppTOML’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++11 -I"/opt/R/4.2.1/lib/R/include" -DNDEBUG -I../inst/include/ -DCPPTOML_USE_MAP -I'/opt/R/4.2.1/lib/R/library/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/opt/R/4.2.1/lib/R/include" -DNDEBUG -I../inst/include/ -DCPPTOML_USE_MAP -I'/opt/R/4.2.1/lib/R/library/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c parse.cpp -o parse.o
In file included from parse.cpp:28:0:
../inst/include/toml.hpp: In static member function ‘static std::string includize::toml_spec::unescape_filename(const string&)’:
../inst/include/toml.hpp:29:66: error: no matching function for call to ‘regex_replace(const string&, std::regex, const char [2])’
         return std::regex_replace(str, std::regex("\\\\\""), "\"");
                                                                  ^
../inst/include/toml.hpp:29:66: note: candidates are:
In file included from /usr/include/c++/4.8.2/regex:62:0,
                 from ../inst/include/includize.hpp:7,
                 from ../inst/include/toml.hpp:4,
                 from parse.cpp:28:
/usr/include/c++/4.8.2/bits/regex.h:2162:5: note: template _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
     ^
/usr/include/c++/4.8.2/bits/regex.h:2162:5: note:   template argument deduction/substitution failed:
In file included from parse.cpp:28:0:
../inst/include/toml.hpp:29:66: note:   deduced conflicting types for parameter ‘_Bi_iter’ (‘std::basic_regex’ and ‘const char*’)
         return std::regex_replace(str, std::regex("\\\\\""), "\"");
                                                                  ^
In file included from /usr/include/c++/4.8.2/regex:62:0,
                 from ../inst/include/includize.hpp:7,
                 from ../inst/include/toml.hpp:4,
                 from parse.cpp:28:
/usr/include/c++/4.8.2/bits/regex.h:2182:5: note: template std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(const basic_string<_Ch_type>& __s,
     ^
/usr/include/c++/4.8.2/bits/regex.h:2182:5: note:   template argument deduction/substitution failed:
In file included from parse.cpp:28:0:
../inst/include/toml.hpp:29:66: note:   mismatched types ‘const std::basic_string<_Ch_type>’ and ‘const char [2]’
         return std::regex_replace(str, std::regex("\\\\\""), "\"");
                                                                  ^
make: *** [parse.o] Error 1
ERROR: compilation failed for package ‘RcppTOML’
* removing ‘/opt/R/4.2.1/lib/R/library/RcppTOML’
* restoring previous ‘/opt/R/4.2.1/lib/R/library/RcppTOML’

The downloaded source packages are in
	‘/tmp/RtmpfpnJuK/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages(update[instlib == l, "Package"], l, contriburl = contriburl,  :
  installation of package ‘RcppTOML’ had non-zero exit status
> 

Analysis:
If one actually reads the error log, one finds it's actually the headers that are not properly picked up,
although the headers belonging to the used compiler are available in the standard path:

# /usr/include/c++
total 24
drwxr-xr-x.  3 root root    45 Jun 28 16:04 .
drwxr-xr-x. 92 root root 12288 Feb  7 11:52 ..
drwxr-xr-x. 12 root root  4096 Jul 12  2021 4.8.2
lrwxrwxrwx.  1 root root     5 Jul 12  2021 4.8.5 -> 4.8.2
lrwxrwxrwx.  1 root root    43 Jun 28 16:04 8.3.1 -> /opt/rh/devtoolset-8/root/usr/include/c++/8
# /usr/include/c++/4.8.2/bits/regex.h
-rw-r--r--. 1 root root 85498 Sep 30  2020 /usr/include/c++/4.8.2/bits/regex.h
# /usr/include/c++/8.3.1/bits/regex.h
-rw-r--r--. 1 root root 97402 Mar 27  2020 /usr/include/c++/8.3.1/bits/regex.h

Instead the false old compiler's header version is chosen over the header version belonging to the currently used compiler. Which must fail, because regex prototype is not implemented in 4.8.2.

Comparison of make config in source for both R-packages unveils following difference:

RFast: PKG_CPPFLAGS = -I../inst/include
RcppTOML: PKG_CPPFLAGS = -I../inst/include/ -DCPPTOML_USE_MAP

Can't figure out whether/how -DCPPTOML_USE_MAP might contribute to this different behaviour/outcome of detecting the proper headers belonging to the already successfully detected compiler which would meet the requirements of RcppTOML otherwise.

Best

Problems with encoding (with non-ASCII chars)

I run into encoding issues when parsing files as well as R characters.

Parsing from text (R characters):

> test_input <- enc2utf8("value='Žluťoučký kůň'")
> Encoding(test_input)
[1] "UTF-8"
> test_output <- RcppTOML::parseTOML(test_input, fromFile = FALSE)$value
> cat(test_output)
Žluťoučký ků�
> Encoding(test_output)
[1] "unknown"

The encoding attribute is lost. But may be set again

> Encoding(test_output) <- "UTF-8"
> cat(test_output)
Žluťoučký kůň

Parsing from files

Example: test.txt

> test_file <- RcppTOML::parseTOML("test.txt
")
> test_file$value
[1] "Ĺ˝luĹĄouÄŤkĂ˝ kĹŻĹ\u0088"
> Encoding(test_file$value)
[1] "unknown"
> Encoding(test_file$value) <- "UTF-8"
> test_file$value
[1] "Žluťoučký kůň"

TOML files are assumed to be UTF-8 Unicode texts. However R characters obtained from parsing via parseTOML() are labeled as "unknown" encoding.

In case of files, the solution may be relatively easy, I think. We can assume that input is UTF-8 and label every string output as "UTF-8".

A windows version?

I think the title is obvious. I know there are problems with Rtools C++ compiler, but so what? what would happen? will you wait until some unknown day that Rtools will upgrade?

Handling of special characters (line breaks etc..)

I am trying to understand why parsing of TOML files with multi-line strings such as this

value = '''
Hellow
world!
'''

yields escaped special characters:

List of 1
 $ value: chr "Hellow\\nworld!\\n"

Can't we get this?

List of 1
 $ value: chr "Hellow\nworld!\n"

Am I missing something?
Thanks

write TOML files?

Maybe this is out of scope, but it would be nice to write a list to a TOML file. I think the upstream cpptoml library has an example program of serializing an object to a stream (examples/build_toml.cpp). Perhaps that can be ported without too much headache.

Inconsistent Treatment of dates

I'm hitting an issue where depending on whether I put dates into arrays or not I get different object types in R.

Here is my TOML file:

[section]
date = "2017-01-01"
date_array = ["2017-01-01", "2017-01-01", "2017-01-01"]
date_unqoted = 2016-01-01
date_array_unquoted = [2016-01-01, 2016-01-01, 2016-01-01, 2016-01-01]

And R code:

library(RcppTOML)
toml <- parseTOML("date_bug.toml")
str(toml)

Which results in:

List of 1
 $ section:List of 4
  ..$ date               : chr "2017-01-01"
  ..$ date_array         : chr [1:3] "2017-01-01" "2017-01-01" "2017-01-01"
  ..$ date_array_unquoted: num [1:4] 16801 16801 16801 16801
  ..$ date_unqoted       : Date[1:1], format: "2016-01-01"
 - attr(*, "class")= chr [1:2] "toml" "list"
 - attr(*, "file")= chr "date_bug.toml"

as.Date(toml$date_array_unquoted, origin="1970-01-01") will return the right result, but it seems to me that this should be a date vector by default.

Odd interaction with plumber

Moving issue rstudio/plumber#293 over to rcpptoml

From original post:


With a restarted console, I can parse the following TOML file (tmp.toml) with no errors:

# tmp.toml

[database]
host = "0.0.0.0"
user = "toto"
> RcppTOML::parseToml("tmp.toml")
List of 1
 $ database:List of 2
  ..$ host: chr "0.0.0.0"
  ..$ user: chr "toto"

Then, I can start plumber with the following simple example:

# example.R

# plumber.R

#* Echo back the input
#* @param msg The message to echo
#* @get /echo
function(msg=""){
  list(msg = paste0("The message is: '", msg, "'"))
}
> plumber::plumb("example.R")$run()
Starting server to listen on port 6639
Running the swagger UI at http://127.0.0.1:6639/__swagger__/

But, if I stop the API, and try to parse again the toml file, I get the following error:

> RcppTOML::parseToml("tmp.toml")
Error in tomlparseImpl(path.expand(input), verbose, fromFile) : 
'---did you forget a '#'? at line 1

Any idea, why it's causing an error after calling plumber ? It looks like plumber is loading RcppTOML and changing its behavior.

This is my sessionInfo at the beginning:

> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C                   LC_TIME=French_France.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.4.4 tools_3.4.4    yaml_2.2.0  

And at the end.

> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C                   LC_TIME=French_France.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] plumber_0.4.6  compiler_3.4.4 magrittr_1.5   R6_2.2.2       RcppTOML_0.1.3 promises_1.0.1
 [7] later_0.7.3    tools_3.4.4    rstudioapi_0.7 yaml_2.2.0     crayon_1.3.4   Rcpp_0.12.18  
[13] stringi_1.1.7  jsonlite_1.5   httpuv_1.4.5

files.zip

is the array behavior correct?

Hi Dirk,

Maybe I am reading the spec for TOML incorrectly, but using the following example:

## Array of Tables

# These can be expressed by using a table name in double brackets. Each table
# with the same double bracketed name will be an element in the array. The
# tables are inserted in the order encountered.

[[products]]

name = "Hammer"
sku = 738594937

[[products]]

[[products]]

name = "Nail"
sku = 284758393
color = "gray"

I would expect the resulting structure to be a list of lists

output <- list(products = list(
        list(name = "Hammer", sku = 738594937),
        list(), 
        list(name = "Nail", sku = 284758393, color = "gray")
       )
)

output$product # gives a list of lists

This seems consistent with the example given https://github.com/toml-lang/toml#user-content-array-of-tables

vs the current implementation, which gives

List of 3
 $ products:List of 2
  ..$ name: chr "Hammer"
  ..$ sku : int 738594937
 $ products: list()
 $ products:List of 3
  ..$ color: chr "gray"
  ..$ name : chr "Nail"
  ..$ sku  : int 284758393

which seems the equivalent of

output <- list(products = list(name = "Hammer", sku = 738594937),
      products = list(), 
      products = list(name = "Nail", sku = 284758393, color = "gray")
)

output$product # only gives the list of the first product

which makes it 'impossible' to query by name

Does UTF encoding work?

I save the following TOML_test file in UTF-8 (on Windows 10) :

title = "TOML Example"
[owner]
name = "äöüßà"

parseTOML("J:/my/path/TOML_test.toml")
List of 2
$ owner:List of 1
..$ name: chr "äöüßà "
$ title: chr "TOML Example"

There is no such issue with yaml:

yaml.load_file("J:/my/path/YAML_test.yaml")
$Überschrift
$Überschrift$Typ
[1] "äöüßà"

Cannot install the RcppTOML packages in a CentOS 7.x system

Compiling error for RcppTOML. It seems that there is some C++ code compiling error. I do not know if there is some dependence missing or should I upgrade the C++ compiler.

Installing package into ‘/home/zyy/R/x86_64-redhat-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/RcppTOML_0.1.7.tar.gz'
Content type 'application/x-gzip' length 42551 bytes (41 KB)

downloaded 41 KB

* installing *source* package ‘RcppTOML’ ...
** package ‘RcppTOML’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I../inst/include/ -DCPPTOML_USE_MAP -I"/home/zyy/R/x86_64-redhat-linux-gnu-library/3.6/Rcpp/include" -I/usr/local/include  -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c RcppExports.cpp -o RcppExports.o
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I../inst/include/ -DCPPTOML_USE_MAP -I"/home/zyy/R/x86_64-redhat-linux-gnu-library/3.6/Rcpp/include" -I/usr/local/include  -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c parse.cpp -o parse.o
In file included from parse.cpp:28:0:
../inst/include/toml.hpp: In static member function ‘static std::string includize::toml_spec<char>::unescape_filename(const string&)’:
../inst/include/toml.hpp:29:66: error: no matching function for call to ‘regex_replace(const string&, std::regex, const char [2])’
         return std::regex_replace(str, std::regex("\\\\\""), "\"");
                                                                  ^
../inst/include/toml.hpp:29:66: note: candidates are:
In file included from /usr/include/c++/4.8.2/regex:62:0,
                 from ../inst/include/includize.hpp:7,
                 from ../inst/include/toml.hpp:4,
                 from parse.cpp:28:
/usr/include/c++/4.8.2/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
     ^
/usr/include/c++/4.8.2/bits/regex.h:2162:5: note:   template argument deduction/substitution failed:
In file included from parse.cpp:28:0:
../inst/include/toml.hpp:29:66: note:   deduced conflicting types for parameter ‘_Bi_iter’ (‘std::basic_regex<char>’ and ‘const char*’)
         return std::regex_replace(str, std::regex("\\\\\""), "\"");
                                                                  ^
In file included from /usr/include/c++/4.8.2/regex:62:0,
                 from ../inst/include/includize.hpp:7,
                 from ../inst/include/toml.hpp:4,
                 from parse.cpp:28:
/usr/include/c++/4.8.2/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(const basic_string<_Ch_type>& __s,
     ^
/usr/include/c++/4.8.2/bits/regex.h:2182:5: note:   template argument deduction/substitution failed:
In file included from parse.cpp:28:0:
../inst/include/toml.hpp:29:66: note:   mismatched types ‘const std::basic_string<_Ch_type>’ and ‘const char [2]’
         return std::regex_replace(str, std::regex("\\\\\""), "\"");
                                                                  ^
../inst/include/toml.hpp:30:5: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
make: *** [parse.o] Error 1
ERROR: compilation failed for package ‘RcppTOML’
* removing ‘/home/zyy/R/x86_64-redhat-linux-gnu-library/3.6/RcppTOML’
Warning in install.packages :
  installation of package ‘RcppTOML’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/Rtmp8iHCvU/downloaded_packages’

Anyone has a clue on this?

Many thanks,

Yuanyuan

error when installing

Hi I tried to install this on a CentOS box but I keep getting this error. Do you know how to fix this?
thanks.
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

In file included from parse.cpp:28:0:
../inst/include/toml.hpp: In static member function ‘static std::string includize::toml_spec<char>::unescape_filename(const string&)’:
../inst/include/toml.hpp:29:66: error: no matching function for call to ‘regex_replace(const string&, std::regex, const char [2])’
         return std::regex_replace(str, std::regex("\\\\\""), "\"");
                                                                  ^
../inst/include/toml.hpp:29:66: note: candidates are:
In file included from /usr/include/c++/4.8.2/regex:62:0,
                 from ../inst/include/includize.hpp:7,
                 from ../inst/include/toml.hpp:4,
                 from parse.cpp:28:
/usr/include/c++/4.8.2/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
     ^
/usr/include/c++/4.8.2/bits/regex.h:2162:5: note:   template argument deduction/substitution failed:
In file included from parse.cpp:28:0:
../inst/include/toml.hpp:29:66: note:   deduced conflicting types for parameter ‘_Bi_iter’ (‘std::basic_regex<char>’ and ‘const char*’)
         return std::regex_replace(str, std::regex("\\\\\""), "\"");
                                                                  ^
In file included from /usr/include/c++/4.8.2/regex:62:0,
                 from ../inst/include/includize.hpp:7,
                 from ../inst/include/toml.hpp:4,
                 from parse.cpp:28:
/usr/include/c++/4.8.2/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(const basic_string<_Ch_type>& __s,
     ^
/usr/include/c++/4.8.2/bits/regex.h:2182:5: note:   template argument deduction/substitution failed:
In file included from parse.cpp:28:0:
../inst/include/toml.hpp:29:66: note:   mismatched types ‘const std::basic_string<_Ch_type>’ and ‘const char [2]’
         return std::regex_replace(str, std::regex("\\\\\""), "\"");
                                                                  ^
make: *** [parse.o] Error 1
ERROR: compilation failed for package ‘RcppTOML’

Installation issue

Can some one help us on this

R version: 3.3.2
c++ version : 4.9.2

Error:

R CMD INSTALL RcppTOML_0.1.3.tar.gz

  • installing source package ‘RcppTOML’ ...
    ** package ‘RcppTOML’ successfully unpacked and MD5 sums checked
    ** libs
    gcc -std=c++0x -std=c++0x -fPIC -I/opt/local/qr/qualifiedr/lib64/microsoft-r/9.0/lib64/R/include -DNDEBUG -I../inst/include/ -DCPPTOML_USE_MAP -DU_STATIC_IMPLEMENTATION -I"/opt/local/tools/library/amgenNonQualified/Rcpp/include" -c RcppExports.cpp -o RcppExports.o
    RcppExports.cpp:1:0: warning: -fPIC ignored for target (all code is position independent)
    // Generated by using Rcpp::compileAttributes() -> do not edit by hand
    ^
    In file included from /opt/local/tools/library/amgenNonQualified/Rcpp/include/RcppCommon.h:121:0,
    from /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp.h:27,
    from RcppExports.cpp:4:
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/routines.h: In function 'long unsigned int Rcpp::internal::enterRNGScope()':
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/routines.h:81:9: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
    }
    ^
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/routines.h: In function 'long unsigned int Rcpp::internal::exitRNGScope()':
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/routines.h:87:9: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
    }
    ^
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/routines.h: In function 'SEXPREC* rcpp_get_stack_trace()':
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/routines.h:126:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
    }
    ^
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/routines.h: In function 'SEXPREC* rcpp_set_stack_trace(SEXP)':
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/routines.h:132:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
    }
    ^
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/routines.h: In function 'std::string demangle(const string&)':
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/routines.h:138:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
    }
    ^
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/routines.h: In function 'void* dataptr(SEXP)':
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/routines.h:210:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
    }
    ^
    gcc -std=gnu99 -I/opt/local/qr/qualifiedr/lib64/microsoft-r/9.0/lib64/R/include -DNDEBUG -I../inst/include/ -DCPPTOML_USE_MAP -DU_STATIC_IMPLEMENTATION -I"/opt/local/tools/library/amgenNonQualified/Rcpp/include" -fpic -DU_STATIC_IMPLEMENTATION -O2 -g -c init.c -o init.o
    gcc -std=c++0x -std=c++0x -fPIC -I/opt/local/qr/qualifiedr/lib64/microsoft-r/9.0/lib64/R/include -DNDEBUG -I../inst/include/ -DCPPTOML_USE_MAP -DU_STATIC_IMPLEMENTATION -I"/opt/local/tools/library/amgenNonQualified/Rcpp/include" -c parse.cpp -o parse.o
    parse.cpp:1:0: warning: -fPIC ignored for target (all code is position independent)
    // -- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; --
    ^
    parse.cpp: In function 'SEXPREC* getValue(const std::shared_ptrcpptoml::base&)':
    parse.cpp:119:41: error: no matching function for call to 'Rcpp::DatetimeVector::DatetimeVector(int, const char [4])'
    Rcpp::DatetimeVector dt(1, "UTC");
    ^
    parse.cpp:119:41: note: candidates are:
    In file included from /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp.h:61:0,
    from parse.cpp:27:
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:34:9: note: Rcpp::DatetimeVector::DatetimeVector(int)
    DatetimeVector(int n) : GreedyVector<Datetime, DatetimeVector>(n) {}
    ^
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:34:9: note: candidate expects 1 argument, 2 provided
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:33:9: note: Rcpp::DatetimeVector::DatetimeVector(SEXP)
    DatetimeVector(SEXP vec) : GreedyVector<Datetime, DatetimeVector>(vec) {}
    ^
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:33:9: note: candidate expects 1 argument, 2 provided
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:31:11: note: Rcpp::DatetimeVector::DatetimeVector(const Rcpp::DatetimeVector&)
    class DatetimeVector : public GreedyVector<Datetime, DatetimeVector> {
    ^
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:31:11: note: candidate expects 1 argument, 2 provided
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:31:11: note: Rcpp::DatetimeVector::DatetimeVector(Rcpp::DatetimeVector&&)
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:31:11: note: candidate expects 1 argument, 2 provided
    parse.cpp:133:41: error: no matching function for call to 'Rcpp::DatetimeVector::DatetimeVector(int, const char [4])'
    Rcpp::DatetimeVector dt(1, "UTC");
    ^
    parse.cpp:133:41: note: candidates are:
    In file included from /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp.h:61:0,
    from parse.cpp:27:
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:34:9: note: Rcpp::DatetimeVector::DatetimeVector(int)
    DatetimeVector(int n) : GreedyVector<Datetime, DatetimeVector>(n) {}
    ^
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:34:9: note: candidate expects 1 argument, 2 provided
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:33:9: note: Rcpp::DatetimeVector::DatetimeVector(SEXP)
    DatetimeVector(SEXP vec) : GreedyVector<Datetime, DatetimeVector>(vec) {}
    ^
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:33:9: note: candidate expects 1 argument, 2 provided
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:31:11: note: Rcpp::DatetimeVector::DatetimeVector(const Rcpp::DatetimeVector&)
    class DatetimeVector : public GreedyVector<Datetime, DatetimeVector> {
    ^
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:31:11: note: candidate expects 1 argument, 2 provided
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:31:11: note: Rcpp::DatetimeVector::DatetimeVector(Rcpp::DatetimeVector&&)
    /opt/local/tools/library/amgenNonQualified/Rcpp/include/Rcpp/DatetimeVector.h:31:11: note: candidate expects 1 argument, 2 provided
    make: *** [parse.o] Error 1
    ERROR: compilation failed for package ‘RcppTOML’

Bad Parsing of Array of Tables

Here's my toml file, taken straight from the spec page:

[[fruit]]
  name = "apple"

  [fruit.physical]
    color = "red"
    shape = "round"

  [[fruit.variety]]
    name = "red delicious"

  [[fruit.variety]]
    name = "granny smith"

[[fruit]]
  name = "banana"

  [[fruit.variety]]
    name = "plantain"

Using the following code:

library(RcppTOML)
cfg <- parseTOML("toml_test.toml")
str(cfg)

I get the following output:

Other: variety
Other: variety
List of 1
 $ fruit:Dotted pair list of 2
  ..$ :List of 3
  .. ..$ name    : chr "apple"
  .. ..$ physical:List of 2
  .. .. ..$ color: chr "red"
  .. .. ..$ shape: chr "round"
  .. ..$         : chr "variety"
  ..$ :List of 2
  .. ..$ name: chr "banana"
  .. ..$     : chr "variety"
 - attr(*, "class")= chr [1:2] "toml" "list"
 - attr(*, "file")= chr "toml_test.toml"

It seems to me that in both situations "variety" doesn't actually seem to be parsed as a list, but instead parsed an an empty character?

cfg$fruit
[[1]]
[[1]]$name
[1] "apple"

[[1]]$physical
[[1]]$physical$color
[1] "red"

[[1]]$physical$shape
[1] "round"


[[1]][[3]]
[1] "variety"


[[2]]
[[2]]$name
[1] "banana"

[[2]][[2]]
[1] "variety"

Session Info:

R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.7 (Santiago)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RcppTOML_0.1.2

loaded via a namespace (and not attached):
 [1] R6_2.2.0        magrittr_1.5    IRdisplay_0.4.4 pbdZMQ_0.2-4   
 [5] tools_3.3.2     Rcpp_0.12.10    crayon_1.3.2    uuid_0.1-2     
 [9] stringi_1.1.5   IRkernel_0.7.1  jsonlite_1.4    stringr_1.2.0  
[13] digest_0.6.12   repr_0.12.0     evaluate_0.10  

Compilation fails on aarch64

I'm trying to update RcppTOML on Raspberry Pi OS 64bit, it is based on Debian Buster so the latest g++ / gcc versions available are 10.2.1 and the compilation process fails with this error message:

g++ -std=gnu++17 -I"/opt/R/release/lib/R/include" -DNDEBUG -I../inst/include -I'/opt/R/release/lib/R/site-library/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c parse.cpp -o parse.o
In file included from ../inst/include/toml++/toml.h:39,
                 from parse.cpp:22:
../inst/include/toml++/impl/forward_declarations.h:633:22: error: ‘_Float16’ was not declared in this scope; did you mean ‘_Float64’?
  633 |  struct float_traits<_Float16> : float_traits_base<_Float16, __FLT16_MANT_DIG__, __FLT16_DIG__>
      |                      ^~~~~~~~
      |                      _Float64
../inst/include/toml++/impl/forward_declarations.h:633:30: error: template argument 1 is invalid
  633 |  struct float_traits<_Float16> : float_traits_base<_Float16, __FLT16_MANT_DIG__, __FLT16_DIG__>
      |                              ^
../inst/include/toml++/impl/forward_declarations.h:633:52: error: ‘_Float16’ was not declared in this scope; did you mean ‘_Float64’?
  633 |  struct float_traits<_Float16> : float_traits_base<_Float16, __FLT16_MANT_DIG__, __FLT16_DIG__>
      |                                                    ^~~~~~~~
      |                                                    _Float64
../inst/include/toml++/impl/forward_declarations.h:633:95: error: template argument 1 is invalid
  633 |  struct float_traits<_Float16> : float_traits_base<_Float16, __FLT16_MANT_DIG__, __FLT16_DIG__>
      |                                                                                               ^
../inst/include/toml++/impl/forward_declarations.h:654:22: error: ‘_Float16’ was not declared in this scope; did you mean ‘_Float64’?
  654 |  struct value_traits<_Float16> : float_traits<_Float16>
      |                      ^~~~~~~~
      |                      _Float64
../inst/include/toml++/impl/forward_declarations.h:654:30: error: template argument 1 is invalid
  654 |  struct value_traits<_Float16> : float_traits<_Float16>
      |                              ^
../inst/include/toml++/impl/forward_declarations.h:654:47: error: ‘_Float16’ was not declared in this scope; did you mean ‘_Float64’?
  654 |  struct value_traits<_Float16> : float_traits<_Float16>
      |                                               ^~~~~~~~
      |                                               _Float64
../inst/include/toml++/impl/forward_declarations.h:654:55: error: template argument 1 is invalid
  654 |  struct value_traits<_Float16> : float_traits<_Float16>
      |                                                       ^
make[1]: *** [/opt/R/release/lib/R/etc/Makeconf:178: parse.o] Error 1

The compilation goes well on Ubuntu 22.04 with g++ 11.3.0 which is why I think this is a g++ / gcc related issue but maybe there is a walkaround you can implement on your side?

installation problems

Trying to install the package I get

> install.packages("RcppTOML")
Installing package into ‘/home/aleha/R/4.2’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository NA/src/contrib:
  cannot open URL 'NA/src/contrib/PACKAGES'
trying URL 'https://cran.rstudio.com/src/contrib/RcppTOML_0.2.2.tar.gz'
Content type 'application/x-gzip' length 141195 bytes (137 KB)
==================================================
downloaded 137 KB

* installing *source* package ‘RcppTOML’ ...
** package ‘RcppTOML’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++17 -I"/opt/R/R-4.2.3.intel/include" -DNDEBUG -I../inst/include -DTOML_ENABLE_FLOAT16=0 -I'/home/aleha/R/4.2/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++17 -I"/opt/R/R-4.2.3.intel/include" -DNDEBUG -I../inst/include -DTOML_ENABLE_FLOAT16=0 -I'/home/aleha/R/4.2/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c parse.cpp -o parse.o
g++ -std=gnu++17 -shared -L/opt/R/R-4.2.3.intel/lib -L/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7 -L/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-0.el7_9.x86_64/jre/lib/amd64/server -ljvm -L/usr/local/lib -L/home/aleha/local/lib -o RcppTOML.so RcppExports.o parse.o -L/opt/R/R-4.2.3.intel/lib -lR
installing to /home/aleha/R/4.2/00LOCK-RcppTOML/00new/RcppTOML/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘RcppTOML’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/aleha/R/4.2/00LOCK-RcppTOML/00new/RcppTOML/libs/RcppTOML.so':
  /home/aleha/R/4.2/00LOCK-RcppTOML/00new/RcppTOML/libs/RcppTOML.so: undefined symbol: _ZNSt18basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/aleha/R/4.2/RcppTOML’

The downloaded source packages are in
	‘/tmp/RtmpE2a2jC/downloaded_packages’
Warning message:
In install.packages("RcppTOML") :
  installation of package ‘RcppTOML’ had non-zero exit status

This is on an older CentOS Linux release 7.9.2009 (Core) system with devtoolset-7.

(On this system there is an R-4.1.2 installation where RcppTOML in version 0.1.7 has been installed and now runs fine.)

thoughts some custom parsers which can wrap around rcpptoml

hi @eddelbuettel, I recently found out about toml, and really like the clean definition.

A while back I had written a pkg params, which we heavily use in flowr. We are using tsv files for configuration, to make it simple instead of yaml etc. However, toml, strikes a much better balance.

I would appreciate your thoughts on being able to update values, in a sequential manner.

Imagine a scenario of baseline configuration, and then add some project specific configurations. We would like to update the values, by loading new files. We achieved this in params via the following:

library(params)
#> Loading required package: whisker

# create a new env for params:
opts = params::new_opts()

# currently this is empty
opts$get()
#> named list()
#> attr(,"class")
#> [1] "opts" "list"

# one can load a tsv, of key  value using
# opts$load("conf_base.tsv")
# opts$load("conf_project1.tsv")

# as a simpler example can use this `options` in R
# this exact rendering is followed when loading files as well.
# set some values
opts$set(
  name = "mytool",
  basepath = "~/apps/mytool", 
  binpath = "{{{basepath}}}/bin")

# get the values:
opts$get("binpath")
#> [1] "~/apps/mytool/bin"

# update a path
opts$set(name = "newtool")

opts$get("name")
#> [1] "newtool"

Created on 2019-04-19 by the reprex package (v0.2.1)

parse.o Error 1 compilation failed for package 'RcppTOML' when attempting package install.

Hi,

I'm using R version 4.0.2 and have it installed on a RedHat 7 platform.
I've tried running install.packages("RcppTOML") but the following message pops up:

                                                           ^

make: *** [parse.o] Error 1
ERROR: compilation failed for package ‘RcppTOML’

  • removing ‘/z/yechoi/R/x86_64-pc-linux-gnu-library/4.0/RcppTOML’

The downloaded source packages are in
‘/tmp/RtmpHb0Eca/downloaded_packages’
Warning message:
In install.packages("RcppTOML") :
installation of package ‘RcppTOML’ had non-zero exit status

As I am not coding-savvy, I need some help in understanding what's happening and how to resolve this issue.

Thanks,
Yehyun

Install problems with rcpptoml

Hi, I am trying to install the rcpptoml as a prerequisite to installing reticulate but I am getting the following error which is double dutch to me. Any help would be greatly appreciated.

install.packages("RcppTOML")
Installing package into ‘/home/jgarrig1/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/RcppTOML_0.1.7.tar.gz'
Content type 'application/x-gzip' length 42551 bytes (41 KB)
==================================================
downloaded 41 KB

* installing *source* package ‘RcppTOML’ ...
** package ‘RcppTOML’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++11 -I"/opt/R/4.0.5/lib/R/include" -DNDEBUG -I../inst/include/ -DCPPTOML_USE_MAP -I'/opt/R/4.0.5/lib/R/library/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/opt/R/4.0.5/lib/R/include" -DNDEBUG -I../inst/include/ -DCPPTOML_USE_MAP -I'/opt/R/4.0.5/lib/R/library/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c parse.cpp -o parse.o
In file included from parse.cpp:28:0:
../inst/include/toml.hpp: In static member function ‘static std::string includize::toml_spec<char>::unescape_filename(const string&)’:
../inst/include/toml.hpp:29:66: error: no matching function for call to ‘regex_replace(const string&, std::regex, const char [2])’
         return std::regex_replace(str, std::regex("\\\\\""), "\"");
                                                                  ^
../inst/include/toml.hpp:29:66: note: candidates are:
In file included from /usr/include/c++/4.8.2/regex:62:0,
                 from ../inst/include/includize.hpp:7,
                 from ../inst/include/toml.hpp:4,
                 from parse.cpp:28:
/usr/include/c++/4.8.2/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
     ^
/usr/include/c++/4.8.2/bits/regex.h:2162:5: note:   template argument deduction/substitution failed:
In file included from parse.cpp:28:0:
../inst/include/toml.hpp:29:66: note:   deduced conflicting types for parameter ‘_Bi_iter’ (‘std::basic_regex<char>’ and ‘const char*’)
         return std::regex_replace(str, std::regex("\\\\\""), "\"");
                                                                  ^
In file included from /usr/include/c++/4.8.2/regex:62:0,
                 from ../inst/include/includize.hpp:7,
                 from ../inst/include/toml.hpp:4,
                 from parse.cpp:28:
/usr/include/c++/4.8.2/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
     regex_replace(const basic_string<_Ch_type>& __s,
     ^
/usr/include/c++/4.8.2/bits/regex.h:2182:5: note:   template argument deduction/substitution failed:
In file included from parse.cpp:28:0:
../inst/include/toml.hpp:29:66: note:   mismatched types ‘const std::basic_string<_Ch_type>’ and ‘const char [2]’
         return std::regex_replace(str, std::regex("\\\\\""), "\"");
                                                                  ^
make: *** [parse.o] Error 1
ERROR: compilation failed for package ‘RcppTOML’
* removing ‘/home/jgarrig1/R/x86_64-pc-linux-gnu-library/4.0/RcppTOML’
Warning in install.packages :
  installation of package ‘RcppTOML’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/Rtmpi9mgSN/downloaded_packages’

Below is a summary of my session info:

sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.3.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] comorbidity_1.0.2         DBI_1.1.2                 readxl_1.4.0              h2o_3.36.0.4             
 [5] rsparkling_3.36.1.1-1-2.4 sparklyr_1.7.5            dbplyr_2.1.1              forcats_0.5.1            
 [9] stringr_1.4.0             dplyr_1.0.9               purrr_0.3.4               readr_2.1.2              
[13] tidyr_1.2.0               tibble_3.1.7              ggplot2_3.3.6             tidyverse_1.3.1          
[17] pacman_0.5.1             

loaded via a namespace (and not attached):
 [1] lubridate_1.8.0   forge_0.2.0       assertthat_0.2.1  rprojroot_2.0.3   digest_0.6.29     utf8_1.2.2       
 [7] R6_2.5.1          cellranger_1.1.0  backports_1.4.1   reprex_2.0.1      httr_1.4.3        pillar_1.7.0     
[13] rlang_1.0.2       rstudioapi_0.13   r2d3_0.2.6        htmlwidgets_1.5.4 RCurl_1.98-1.6    munsell_0.5.0    
[19] broom_0.8.0       compiler_4.0.5    modelr_0.1.8      pkgconfig_2.0.3   base64enc_0.1-3   htmltools_0.5.2  
[25] tidyselect_1.1.2  fansi_1.0.3       crayon_1.5.1      tzdb_0.3.0        withr_2.5.0       bitops_1.0-7     
[31] grid_4.0.5        jsonlite_1.8.0    gtable_0.3.0      lifecycle_1.0.1   magrittr_2.0.3    scales_1.2.0     
[37] cli_3.3.0         stringi_1.7.6     fs_1.5.2          xml2_1.3.3        ellipsis_0.3.2    generics_0.1.2   
[43] vctrs_0.4.1       tools_4.0.5       glue_1.6.2        hms_1.1.1         parallel_4.0.5    fastmap_1.1.0    
[49] colorspace_2.0-3  rvest_1.0.2       haven_2.5.0

parse from string

While updating - one other request would be - I see that you are calling https://github.com/eddelbuettel/rcpptoml/blob/master/src/parse.cpp#L198 for this implementation, but can you think of a reasonable workaround for parsing a string rather than a file, other than writing it out to tmp/ then parsing that?

Namely, one use that I have is giving some structure to comments inside a comment block of a file.

For example, a control stream for the nonlinear mixed effect modeling language that I use looks like:

$PROB <some text>
;; comments
;; ...
$PK
...

Where the current practice is just to parse text

;; based on: <some prior model>
;; details: <some text>

whereas I would like to do

;; based_on = <prior model>
;; [details]
;; comment1 = <text>
;; comment2 = <more text>
;; [etc]

as white space is so flexible in toml it makes it perfect for just stripping the proceeding ;; and then parsing the rest.

Worst case after stripping I'll just write it out to a tmp file then parse that in, but it would be cool to just be able to concat the relevant lines and pass that string to a parse_toml() function

compilation aborted for parse.cpp

Trying to build ~ on our campus cluster.

cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)

icpc -v
icpc version 19.0.1.144 (gcc version 8.5.0 compatibility)

cat ~/.R/Makevars
MAKEFLAGS = -j20
#the following attempt to avoid missing CXX17 definition in R config
CXX17 = icpc
CXX17STD = -std=c++17
CXX17FLAGS = -fPIC -qopenmp -O3 -ipo -xHost -multiple-processes -flto
CXX17PICFLAGS = -fpic

icpc -std=c++17 -I"/share/apps/R/4.1.1-intel/lib64/R/include" -DNDEBUG -I../inst/include -DTOML_ENABLE_FLOAT16=0 -I'/lustre/project/hpcstaff/<user>/R/Library/Rcpp/include' -I/usr/local/include -fpic -fPIC -qopenmp -O3 -ipo -xHost -multiple-processes -flto -c parse.cpp -o parse.o In file included from ../inst/include/toml++/toml.h(45),
from parse.cpp(22):
../inst/include/toml++/impl/make_node.h(15): warning #1292: unknown attribute "returns_nonnull"
TOML_ATTR(returns_nonnull)
^

In file included from ../inst/include/toml++/toml.h(63),
from parse.cpp(22):
../inst/include/toml++/impl/node.h(936): internal error: assertion failed at: "shared/cfe/edgcpfe/class_decl.c", line 3662

                    return do_visit(static_cast<Func&&>(visitor), *this);
                                                                        ^

compilation aborted for parse.cpp (code 4)
make: *** [parse.o] Error 4
make: *** Waiting for unfinished jobs....
ERROR: compilation failed for package ‘RcppTOML’

Please let me know if I can supply more information. Thanks.
Best,
CB

compilation failed for package ‘RcppTOML’

Hello,

I am trying to install Seurat and Signac on R v4.1.0 using Linux and keep getting an error about the dependency RcppTOML failing to compile. I have looked at other threads discussing this and upgraded to compilers/gcc/7.2.0 and also tried to install it using conda, but I am continuing to get this error. Any advice?

`> install.packages("Seurat")
Installing package into ‘/mnt/scratch2/users//R/lib’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Secure CRAN mirrors
Selection: 75
also installing the dependencies ‘RcppTOML’, ‘leiden’, ‘reticulate’

  • installing source package ‘RcppTOML’ ...
    ** package ‘RcppTOML’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    /usr/bin/g++ -std=gnu++11 -I"/opt/gridware/depots/54e7fb3c/el7/pkg/apps/R/4.1.0/gcc-4.8.5+lapack-3.5.0+blas-3.6.0/lib64/R/include" -DNDEBUG -I../inst/include/ -DCPPTOML_USE_MAP -I'/mnt/scratch2/users//R/lib/Rcpp/include' -I/usr/local/include -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o
    /usr/bin/g++ -std=gnu++11 -I"/opt/gridware/depots/54e7fb3c/el7/pkg/apps/R/4.1.0/gcc-4.8.5+lapack-3.5.0+blas-3.6.0/lib64/R/include" -DNDEBUG -I../inst/include/ -DCPPTOML_USE_MAP -I'/mnt/scratch2/users//R/lib/Rcpp/include' -I/usr/local/include -fpic -g -O2 -c parse.cpp -o parse.o
    In file included from parse.cpp:28:0:
    ../inst/include/toml.hpp: In static member function ‘static std::string includize::toml_spec::unescape_filename(const string&)’:
    ../inst/include/toml.hpp:29:66: error: no matching function for call to ‘regex_replace(const string&, std::regex, const char [2])’
    return std::regex_replace(str, std::regex("\\""), """);
    ^
    ../inst/include/toml.hpp:29:66: note: candidates are:
    In file included from /usr/include/c++/4.8.2/regex:62:0,
    from ../inst/include/includize.hpp:7,
    from ../inst/include/toml.hpp:4,
    from parse.cpp:28:
    /usr/include/c++/4.8.2/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
    regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
    ^
    /usr/include/c++/4.8.2/bits/regex.h:2162:5: note: template argument deduction/substitution failed:
    In file included from parse.cpp:28:0:
    ../inst/include/toml.hpp:29:66: note: deduced conflicting types for parameter ‘_Bi_iter’ (‘std::basic_regex’ and ‘const char*’)
    return std::regex_replace(str, std::regex("\\""), """);
    ^
    In file included from /usr/include/c++/4.8.2/regex:62:0,
    from ../inst/include/includize.hpp:7,
    from ../inst/include/toml.hpp:4,
    from parse.cpp:28:
    /usr/include/c++/4.8.2/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
    regex_replace(const basic_string<_Ch_type>& __s,
    ^
    /usr/include/c++/4.8.2/bits/regex.h:2182:5: note: template argument deduction/substitution failed:
    In file included from parse.cpp:28:0:
    ../inst/include/toml.hpp:29:66: note: mismatched types ‘const std::basic_string<_Ch_type>’ and ‘const char [2]’
    return std::regex_replace(str, std::regex("\\""), """);
    ^
    make: *** [parse.o] Error 1
    ERROR: compilation failed for package ‘RcppTOML’
  • removing ‘/mnt/scratch2/users//R/lib/RcppTOML’
    ERROR: dependency ‘RcppTOML’ is not available for package ‘reticulate’
  • removing ‘/mnt/scratch2/users//R/lib/reticulate’
    ERROR: dependency ‘reticulate’ is not available for package ‘leiden’
  • removing ‘/mnt/scratch2/users//R/lib/leiden’
    ERROR: dependencies ‘leiden’, ‘reticulate’ are not available for package ‘Seurat’
  • removing ‘/mnt/scratch2/users//R/lib/Seurat’

The downloaded source packages are in
‘/tmp/Rtmp8SCqqy/downloaded_packages’
Warning messages:
1: In install.packages("Seurat") :
installation of package ‘RcppTOML’ had non-zero exit status
2: In install.packages("Seurat") :
installation of package ‘reticulate’ had non-zero exit status
3: In install.packages("Seurat") :
installation of package ‘leiden’ had non-zero exit status
4: In install.packages("Seurat") :
installation of package ‘Seurat’ had non-zero exit status
`

can't install on R 3.5.2 ubuntu 14.04

Hi!
May help resolve this issue, please?

* installing *source* package ‘RcppTOML’ ...
** package ‘RcppTOML’ successfully unpacked and MD5 sums checked
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include/ -DCPPTOML_USE_MAP -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include/ -DCPPTOML_USE_MAP -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c parse.cpp -o parse.o
In file included from parse.cpp:28:0:
../inst/include/toml.hpp: In static member function ‘static std::string includize::toml_spec<char>::unescape_filename(const string&)’:
../inst/include/toml.hpp:29:66: error: no matching function for call to ‘regex_replace(const string&, std::regex, const char [2])’
return std::regex_replace(str, std::regex("\\\\\""), "\"");
^
../inst/include/toml.hpp:29:66: note: candidates are:
In file included from /usr/include/c++/4.8/regex:62:0,
from ../inst/include/includize.hpp:7,
from ../inst/include/toml.hpp:4,
from parse.cpp:28:
/usr/include/c++/4.8/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
^
/usr/include/c++/4.8/bits/regex.h:2162:5: note: template argument deduction/substitution failed:
In file included from parse.cpp:28:0:
../inst/include/toml.hpp:29:66: note: deduced conflicting types for parameter ‘_Bi_iter’ (‘std::basic_regex<char>’ and ‘const char*’)
return std::regex_replace(str, std::regex("\\\\\""), "\"");
^
In file included from /usr/include/c++/4.8/regex:62:0,
from ../inst/include/includize.hpp:7,
from ../inst/include/toml.hpp:4,
from parse.cpp:28:
/usr/include/c++/4.8/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type)
regex_replace(const basic_string<_Ch_type>& __s,
^
/usr/include/c++/4.8/bits/regex.h:2182:5: note: template argument deduction/substitution failed:
In file included from parse.cpp:28:0:
../inst/include/toml.hpp:29:66: note: mismatched types ‘const std::basic_string<_Ch_type>’ and ‘const char [2]’
return std::regex_replace(str, std::regex("\\\\\""), "\"");
^
make:
*** [parse.o] Error 1
ERROR: compilation failed for package ‘RcppTOML’

RcppTOML requires newer version of Rcpp

RcppTOML now requires a newer version of Rcpp (>=1.0.8) to compile, rather than the version specified in the DESCRIPTION file (>=0.11.5).

This is due to the change to link against Rcpp/Lightest in 00cce5c, which was only introduced in Rcpp 1.0.8.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.