R can't find MATLAB Runtime - r

I made an R script that generates a command line that's supposed to launch a MATLAB ".exe" file with parameters.
The generated command line looks like this:
cmd = "X:\matlabscript.exe [xxx,xxx,...]"
Then I enter the command in the shell:
shell(cmd)
And I get this error:
Error: Could not find version 9.7 of the MATLAB Runtime.
Attempting to load mclmcrrt9_7.dll.
Please install the correct version of the MATLAB Runtime.
Contact your vendor if you do not have an installer for the MATLAB Runtime.
Warning message:
In shell(cmd) :
l'exécution de 'X:\matlabscript.exe [xxx,xxx,...]' a échoué avec le code d'erreur 65535
When I copy-paste the command in CMD.exe it works fine.
I also added the runtime path in the system environment variables "path" but it didn't change anything.
How can I launch the MATLAB Runtime via R?

Problem solved...
I had to restart the computer as restarting only the R session wasn't enough.
It's working fine now !

Related

R: "internet routines cannot be loaded" when starting from RStudio

I am running Red Hat Enterprise Linux (RHEL) 8.5 with Linux kernel 4.18 and Gnome 3.32.2. In this system, I've got R 4.1.2 compiled with the tool asdf with shared libraries enabled. On top of that, I installed RStudio 2021.09.01-372 from an RPM from the official RStudio website.
When I start Rstudio, the first line of output after the usual R startup is an error:
Error in tools::startDynamicHelp() : internet routines cannot be loaded
I am unable to figure out what's causing this error, and with it I can't run things like refresh CRAN or update packages. But if I start a pure R session from the terminal (instead of Rstudio) this error does not occur.
Some things I tried:
Install the krb5 and libssh2 packages on my host system: Didn't help.
Starting a "pure" R session (both with and without the --vanilla argument) from the Terminal tab within Rstudio also gives this error. If I try to run update.packages() from this session, it pops up a window to select a CRAN mirror then fails with the following:
Warning: failed to download mirrors file (internet routines cannot be loaded); using local file '/home/[my username]/.asdf/installs/R/4.1.2/lib64/R/doc/CRAN_mirrors.csv'
Warning: unable to access index for repository https://cloud.r-project.org/src/contrib:
internet routines cannot be loaded
Warning message:
In download.file(url, destfile = f, quiet = TRUE) :
unable to load shared object '/home/penyuan/.asdf/installs/R/4.1.2/lib64/R/modules//internet.so':
/lib64/libssh.so.4: undefined symbol: EVP_KDF_ctrl, version OPENSSL_1_1_1b
But like I said, the strange thing is if I start an R session outside of Rstudio, these errors don't happen.
Within RStudio, the only workaround I can find is to run this command upon startup (suggested in this thread):
options(download.file.method="wget")
Once this is done, everything else seems to work, such as package updates.
However, I don't want to manually do this every time I start RStudio. So I tried to put it into ~/.Rprofile including a test print() as follows:
print("This is `~/.Rprofile`")
options(download.file.method="wget")
When I open RStudio, I can see the output from the print() call, but the options() command is not run because the original error shows up again. I still have to manually enter options(download.file.method="wget") every time.
I also tried to fold everything into a .First function in ~/.Rprofile as follows:
.First <- function() {
options(download.file.method="wget")
print("This is the `.First` function in `~/.Rprofile`")
}
Unfortunately, same result as before: print()'s output is seen, but options() is not run.
I also made sure that my ~/.Rprofile includes a trailing newline as discussed here. But this didn't help.
The above are the steps I've tried so far.
Why does this error only occur when running RStudio or a terminal within Rstudio? Why doesn't it happen if I start R from a terminal outside of Rstudio?
Is there a way to solve the problem so that the error doesn't happen in the first place? If it can't be solved, how do I set up my ~/.Rprofile so that options(download.file.method="wget") will be run?
Thank you.

Executing R script within R 3.3.1 installed on windows

Sorry for a basic question. I'm trying run a R script called cuffdiff_gtf_attributes (please find it at enter link description here in R 3.3.1 installed on the Windows 7. The script is started with the below line:
#!/usr/bin/env Rscript
When I type cuffdiff_gtf_attributes in R, it says Error: object 'cuffdiff_gtf_attributes' not found. Also, I tried Rscript cuffdiff_gtf_attributes that returned me: Error: unexpected symbol in "Rscript cuffdiff_gtf_attributes".
Moreover, I tried source('cuffdiff_gtf_attributes.R')that seems to work and returned the usage of the script as bellow
Error:
usage: cuffdiff_gtf_attributes --input=<inputGTF> [--output=outputGTF] | --help
But, when I add the arguments as source('cuffdiff_gtf_attributes.R') --input=file.gtf, it says that: Error: object 'file.gtf' not found. I also tried this command as source('cuffdiff_gtf_attributes.R') --input file.gtf, it says that Error: unexpected symbol in "source('cuffdiff_gtf_attributes.R') --input file.gtf"
Sorry, I couldn't post a sample GTF file, you can find a short sample of it at enter link description here
Everything is the current path. Could you please help me out to execute the script?
Thanks in advance
This is a script file. You should run using Rscript instead for Rgui.exe. From a command prompt, navigate to the directory where file.gtf is and run:
"%Programfiles%\R\R-3.3.3\bin\Rscript" cuffdiff_gtf_attributes.R --input=file.gtf

failed to precompile Gurobi (on Windows, using Julia)?

I am trying to run a Julia program using Gurobi solver on Windows.
I have already set up my GUROBI_HOME in windows as C:\gurobi701\win64.
Here is the error message in Atom:
error msg
I have done the following in Julia interactive shell:
Pkg.add("Gurobi")
also
Pkg.update()
Also, I checked whether or not my gurobi license file is not properly set up by running their example:
> gurobi_cl C:\gurobi701\win64\examples\data\coins.lp
The output seems fine: output for gurobi command line
What is the possible error here?
Thanks a lot for help!!!

GOBJECT_INTROSPECTION_CHECK syntax error on configure

On "./configure" of an open source project I get:
user agent OS = Linux
./configure: line 13957: syntax error near unexpected token 0.9.3'
./configure: line 13957: GOBJECT_INTROSPECTION_CHECK(0.9.3)'
make: *** [config.status] Error 2
Ubuntu 12.04 package "gobject-introspection" and "libgirepository1.0-dev" are present. Removing the GOBJECT_INTROSPECTION_CHECK line allows configure to complete, but the project fails a dependency later.
How can I get past this configure step cleanly? Googling for this issue shows bugs filed against numerous OS projects for this same blocking issue, but the usual answer is "install gobject-introspection".
As the OP discovered on his own he had to install the gobject-introspection package to get the m4 macros that were being used.
The error message has the raw macro in it, as configure scripts are generated from configure.in/configure.ac files via m4/etc the fact that the raw macro is in the output file indicates that the macro did not get translated at generation time.
The gobject-introspection m4 files were apparently installed after autogen.sh (or equivalent) was run to generate the configure script. Re-running the autogen.sh script should regenerate the configure script and run the macro correctly.

R script from command line

I wanted to run this example script: http://mazamascience.com/WorkingWithData/?p=912 from Windows command line. So I opened the command line and typed Rscript tryCatch.R 1. However, I keep getting the error message Error: R not found. I did set the PATH environment variable as C:\Programme\R\R-3.0.1\bin. If I just type R.exe, it does start R, but it cannot find the packages that are to be loaded at start (e.g. package 'utils' in options<"defaultPackages"> was not found). I guess I have to set another path to the libraries somewhere, but I haven't got any idea where to do this.
UPDATE: After explicitly typing PATH C:\Programme\R\R-3.0.1\bin (rather than just adding this to the value of the environment variable PATH) it seems that R is found. However, a new problem occurs: In normalizePath<path.expand(path), winslash, mustWork>: path[2] = "C:/Programme/R/R-3.0.1/library": Access denied, the same than for the methods library. Then: Calls: .First ... library -> .getRequiredPackages2 -> library -> normalizePath Execution stopped. I'm using Windows 7 and I do have administrator rights.
Rscript is very handy (R CMD BATCH is the old way to ) specially under windows, But generally under I create a batch file to avoid all path's headache.
For example say launcher.bat:
#echo off
C:
PATH C:\Programme\R\R-3.0.1\bin;%path%
cd PATH_TO_YOUR_RSCRIPT
Rscript tryCatch.R 1
pause
And open a console(using cmd) , go where you have stored your launcher.bat and launch it. Or from the R cosnole using shell:
shell('path_to_launcher\launcher.bat')
I've found out that it was a language-specific problem on Windows 7, similar to what is described here: https://stat.ethz.ch/pipermail/r-help/2011-May/276932.html
After changing PATH to C:\Program Files\R\R-3.0.1\bin the script is properly executed from the command prompt.
Thanks to everyone who tried to help!
I ran into this problem under windows 7, apparently, when setting environment variables>user variables the path is not added into the PATH, so the user must add this path in system variables > PATH
at the end just add the path to your .EXE files and voila.

Resources