GLPK: No such file or directory error when trying to install R package
Asked Answered
H

10

20

I am trying to install sparkTable in R 3.1.0 which depends on Rglpk. I manually installed GPLK on the system and added the libs folder to LD_LIBRARY_PATH before going into R for the install.packages("sparkTable") procedure. I get this error during the installation process. Any ideas?

* installing *source* package ‘Rglpk’ ...
** package ‘Rglpk’ successfully unpacked and MD5 sums checked
** libs
/bin/sh: line 0: cd: GLPK: No such file or directory
make: *** [GLPK.ts] Error 1
ERROR: compilation failed for package ‘Rglpk’
* removing ‘/opt/R/R-3.1.0/lib64/R/library/Rglpk’
ERROR: dependency ‘Rglpk’ is not available for package ‘sparkTable’
* removing ‘/opt/R/R-3.1.0/lib64/R/library/sparkTable’
Hamachi answered 4/8, 2014 at 8:44 Comment(3)
Using install.packages("sparkTable", dependencies=TRUE) helps to solve the problem of dependencies. About GLPK, did you install the headers?Carioca
I get the same error when using install.packages("sparkTable", dependencies=TRUE) . I installed GLPK by downloading it with wget http://ftp.gnu.org/gnu/glpk/glpk-4.54.tar.gz and running ./configure && make && make install. How do I install or point to the headers?Hamachi
On Macs with glpk homebrew install, which puts glpk in /usr/local/lib set export CPATH=/usr/local/includethen it works :)Florella
V
39
sudo apt-get install libglpk-dev

did the trick for me.

Velvavelvet answered 4/8, 2014 at 20:52 Comment(3)
I am on a system without root permissions, and it's a CentOS as well, so I am going to have to find another solution, but thanks for your answer.Hamachi
Worked for me (Ubuntu 16.04, R 3.4.4)Akron
On Fedora, sudo yum install glpk-develPopulation
S
11

I had this problem too. The following steps solved this issue for me. My current setup:

  • OS: Scientifc Linux version 6.5 (on a High Performance Cluster Server)
  • local user, no root access.
  • GLPK was not installed

Install GLPK in a local directory:

wget http://ftp.gnu.org/gnu/glpk/glpk-4.54.tar.gz
tar xfzv glpk-4.54.tar.gz
mkdir GLPK
cd glpk-4.54
./configure --prefix=/home/<username>/GLPK
make
make install

Install Rglpk (0.6-3):

cd ~
wget http://cran.r-project.org/src/contrib/Rglpk_0.6-3.tar.gz
export LIBRARY_PATH=/home/<username>/GLPK/lib
R CMD INSTALL Rglpk_0.6-3.tar.gz
Sauger answered 10/1, 2015 at 18:14 Comment(1)
I had a similar setup, but with Centos 6.5. To get this to work, I also had to run export LD_LIBRARY_PATH=/home/<username>/GLPK/lib and export CPATH=/home/<username>/GLPK/include before running R CMD INSTALL Rglpk_0.6-0.tar.gz.Lipps
A
11

I landed on this page, because I could not update igraph under Windows 10/11, since igraph also requires glpk as per OP. Specifically:

igraph_glpk_support.h:36:10: fatal error: glpk.h: No such file or directory #include <glpk.h> ^~~~~~~~ compilation terminated. make: *** [C:/PROGRA~1/R/R-4.1.1/etc/x64/Makeconf:238: feedback_arc_set.o] Error 1 ERROR: compilation failed for package 'igraph'

  • removing 'C:/Users/xxx/Documents/R/win-library/4.1/igraph'
  • restoring previous 'C:/Users/xxx/Documents/R/win-library/4.1/igraph' Warning in install.packages : installation of package ‘igraph’ had non-zero exit status

I am under Windows 11 (but would be same for Windows 10). Simple resolution is suggested here:

  1. start Rtools Bash (found in all apps, Rtools 4.0 in the Windows menu)
  2. Run pacman -S mingw-w64-x86_64-glpk and confirm with yes (y)
  3. Run pacman -S mingw-w64-x86_64-libxml2 and confirm with yes (y)
  4. Updating igraph in Rstudio now leads to a clean

DONE (igraph)

(there is no need to install anything, add any path, etc... just the above 4 steps)

Approbate answered 15/10, 2021 at 17:45 Comment(7)
pacman -Sy mingw-w64-x86_64-glpk had to use the -Sy command to install if missing.Cadet
Absolutely, or alternatively, you could run pacman -Syu I think to make sure your Rtools is up-to-date.Approbate
I have an issue with this solution - I'm unable to run this command because of SSL certificate issues. Also I'm confused about one of the repositiers it is trying to access r-windows.github.io? that is not a URL that is valid? Has anyone had similar issues?Vogt
i just tried again and it works just fine on my end. This SSL certificate issue is unrelated to the solution provided, it's a setting problem with your connection. You do not give enough information to really help you here. This said, from the little, you provide, I can recommend looking into your Rtools40\etc\pacman.d\ folder. You can see from the etc\pacman.conf file that's where all the repos are being specified. You can edit this to your liking. Hope it helps!Approbate
Thanks @tchevrier, apologies for the clumsy explanation. I've had some clarity on the issue itself, it appears that yes it is a network error and it is due to Rtools not finding the right path for the certificates (which I am told exist). I am also told there is a way to ask Rtools to ignore the need for certificates and that might do the job. Would you know how to do this? I'm expecting it to be in the --option format?Vogt
noted - i have been told you'd need to file a new "ticket" for this, as this is unrelated to OP. lol.Approbate
In my case it worked using i686 package versions. You can check available versions using pacman -Ss glpk.Blocker
H
9

I had this problem and took a good bit of digging in the package to understand what was happening. If Rgplk can't compile its test program when installing, it does something weird, including this bizarre cd to nowhere. Assuming glpk-devel is installed, the reason it can't compile the test program is that it can't find the gplk header as it is in a non-standard directory.

Just set the environment variable CPATH=/usr/include/glpk

and the test program will compile, allowing the package install to proceed normally.

Hydnocarpate answered 12/9, 2014 at 22:37 Comment(2)
Thanks a bunch for this!! Where in the package were you looking for btw? I guess I do not exactly know what R CMD INSTALL does -- ./configure passes without error, and makefile does not exist, so I was not sure where to even look!Pessary
I think it was in the configure script somewhere. I can't remember exactly. I agree it is odd that it doesn't fail but the script itself catches the error and then does something inexplicableHydnocarpate
M
4

If you're on a Debian-based Linux distribution, run this to install GLPK:

sudo apt install libglpk-dev

If you're on MacOS, run this to install GLPK:

brew install glpk

Finally, install the R library:

install.packages("Rglpk")
Miscellaneous answered 4/5, 2020 at 2:40 Comment(4)
do you mean brew install glpk? because there is currently no formula for gltk on homebrewHeeltap
On MacOS, I get this error: /bin/sh: line 0: cd: GLPK: No such file or directoryClipboard
I also got the same error in MACOS. @ClipboardLeanora
Sorry for the typo. It has been fixed.Miscellaneous
E
3

In ubuntu 14.04, all above doesn't work. the following however works, without the need of installing libglpk-dev using apt-get.

download the glpk package from gnu and extract it:

wget http://ftp.gnu.org/gnu/glpk/glpk-4.55.tar.gz tar xvf glpk-4.55.tar.gz

make a GLPK directory in your local path:

mkdir ~/GLPK

configure within glpk:

cd glpk-4.55 ./configure --prefix=$HOME/GLPK cd .. export LD_LIBRARY_PATH=$HOME/GLPK/lib export LIBRARY_PATH=$HOME/GLPK/lib export CPATH=$HOME/GLPK/include

download the Rglpk package from cran and extract it:

wget http://cran.r-project.org/src/contrib/Rglpk_0.6-0.tar.gz tar xvf Rglpk_0.6_0.tar.gz

move the glpk directory into Rglpk/src and rename it to GLPK:

mv glpk-4.55 Rglpk/src/GLPK

now you can install:

R CMD INSTALL Rglpk


now a bit of explanation of what's going on. The "src/Makevars.in" file in the Rglpk package contains a line of code to enter a non-existing directory 'GLPK' within the src/ folder:

(line 11 of Makevars.in)

GLPK.ts: @(cd GLPK && make) touch $@

this is where the problem arises. obviously the code is trying to build glpk within that directory for some unknown reasons. and the solution above is achieved simply by moving the downloaded (and configured) glpk directory there...

Engineman answered 2/6, 2015 at 17:14 Comment(1)
Dude, that's still the case in 2020, my context: docker ubuntu. It would be great to have that Makefile fixed, it's not quite idiomatic to handle a dependency that way.Anticipative
H
1

On Centos, have sudo rights. None of the above worked, but had to install GLPK in /usr/local as suggested in this SO answer. Been trying to install it for about 3 hours fml

Headed answered 30/4, 2015 at 14:55 Comment(0)
B
1

You must install glpk dependency first.

On macOS (via homebrew):

brew install glpk

or in RStudio (via homebrew):

system("brew install glpk")
Boreal answered 28/7, 2017 at 18:19 Comment(0)
L
1

It worked for me when I combined the answers from Simón Ramírez Amaya and shadowleaves:

wget http://ftp.gnu.org/gnu/glpk/glpk-4.54.tar.gz
tar xfzv glpk-4.54.tar.gz
mkdir GLPK
cd glpk-4.54
./configure --prefix=$HOME/GLPK
make
make install
cd ..
export LD_LIBRARY_PATH=$HOME/GLPK/lib
export LIBRARY_PATH=$HOME/GLPK/lib
export CPATH=$HOME/GLPK/include
wget https://cran.r-project.org/src/contrib/Rglpk_0.6-4.tar.gz
R CMD INSTALL Rglpk_0.6-4.tar.gz

To load the library

dyn.load(file.path(Sys.getenv("HOME"), "GLPK", "lib", "libglpk.so"))
library(Rglpk)
Liquidate answered 10/3, 2020 at 9:34 Comment(0)
H
1

The answer of Zhiying Cui is right, however, if your script has some special codes, such as foreach for parallel computing, it may raise an error. A better way is as fellow

If your os is Centos, try

yum install glpk-devel

then just go to R or Rstudio server and

install.packages("Rglpk")
Hagfish answered 27/8, 2021 at 12:25 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.