Closed
Description
Motivation
I am attempting to create a Nix package for an R application which uses Rcpp
.
The nature of Nix is that all installed files are readonly in the Nix store.
Attempting to sourceCpp
such an installed C++ file results in a file io error
.
This is a showstopper for Nix packaging of anything using Rcpp I think. I can understand no good reason for not supporting readonly C++ sources.
Evidence
Working example with writable C++ source:
it23677> Rscript hello-rcpp-world.R
Loading required package: Rcpp
/nix/store/106z10g87sccpaw7n8pnwlalhpxnc85q-R-4.3.3/lib/R/bin/R CMD SHLIB -o 'sourceCpp_2.so' 'hello-cpp-world.cpp'
using C++ compiler: ‘g++ (GCC) 13.2.0’
/nix/store/i53w7x986ifmgzvb8da6zkfms4xzmdrk-gcc-wrapper-13.2.0/bin/c++ -std=gnu++17 -I"/nix/store/106z10g87sccpaw7n8pnwlalhpxnc85q-R-4.3.3/lib/R/include" -DNDEBUG -I"/nix/store/yh83cz7v3vjw6r7nk05d55mkj77m3g3f-r-Rcpp-1.0.12/library/Rcpp/include" -I"/home/guestsi/vc/agr-github/RCpp-readonly-file-io-error" -fpic -g -O2 -c hello-cpp-world.cpp -o hello-cpp-world.o
/nix/store/i53w7x986ifmgzvb8da6zkfms4xzmdrk-gcc-wrapper-13.2.0/bin/c++ -std=gnu++17 -shared -L/nix/store/106z10g87sccpaw7n8pnwlalhpxnc85q-R-4.3.3/lib/R/lib -o sourceCpp_2.so hello-cpp-world.o -L/nix/store/106z10g87sccpaw7n8pnwlalhpxnc85q-R-4.3.3/lib/R/lib -lR
Hello CPP World
Making it readonly breaks things:
it23677> chmod 444 hello-cpp-world.cpp
it23677> Rscript hello-rcpp-world.R
Loading required package: Rcpp
Error: file io error: '/tmp/RtmpCCsssI/sourceCpp-x86_64-pc-linux-gnu-1.0.12/sourcecpp_277bc8f7c72b/hello-cpp-world.cpp'
Execution halted
Exception: Rscript exited with 1
[tty 10]:1:1-27: Rscript hello-rcpp-world.R
hello-rcpp-world.R
source:
require(Rcpp)
sourceCpp(file = "hello-cpp-world.cpp", showOutput = TRUE)
hello_cpp_world()
hello-cpp-world.cpp
source:
#include <iostream>
using namespace std;
// [[Rcpp::export]]
void hello_cpp_world() {
cout << "Hello CPP World" << endl;
}
Version and Platform
I am using Rcpp 1.0.12 with R 4.3.3 on NixOS 24.11. (NixOS is a Linux distro built with Nix.)
Metadata
Metadata
Assignees
Labels
No labels