NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.52k stars 13.7k forks source link

RPostgres rPackage error #46208

Closed ivanbrennan closed 6 years ago

ivanbrennan commented 6 years ago

Issue description

The compilation of RPostgres rPackage fails.

Steps to reproduce

Create a shell.nix:

{ pkgs ? import <nixpkgs> {} }:

let
  rEnv = pkgs.rWrapper.override {
    packages = with pkgs.rPackages; [ RPostgres ];
  };

in with pkgs; mkShell {
  buildInputs = [ postgresql rEnv ];
}

and run nix-shell.

Result:

building '/nix/store/8ckwmk5ws5l94mzmqxf3xm6081alz69s-r-RPostgres-1.1.1.drv'...
...
* installing *source* package 'RPostgres' ...
** package 'RPostgres' successfully unpacked and MD5 sums checked
Using PKG_CFLAGS=
Using PKG_LIBS=-lpq
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libpq was not found. Try installing:
 * deb: libpq-dev (Debian, Ubuntu, etc)
 * rpm: postgresql-devel (Fedora, EPEL)
 * rpm: postgreql8-devel, psstgresql92-devel, postgresql93-devel, or postgresql94-devel (Amazon Linux)
 * csw: postgresql_dev (Solaris)
 * brew: libpq (OSX)
If libpq is already installed, check that either:
(i)  'pkg-config' is in your PATH AND PKG_CONFIG_PATH contains
     a libpq.pc file; or
(ii) 'pg_config' is in your PATH.

I tried adding postgresql.lib, pkg-config, and libpqxx (only because I didn't find a libpq package) to the buildInputs (individually and in combination), but none made any difference.

Technical details

ryantm commented 6 years ago

Trying to reproduce, I got a different issue:

$ nix-shell -I nixpkgs=/home/ryantm/p/nixpkgs -p pkgs.rPackages.RPostgres                                                                                                 
these derivations will be built:                                                                                                                                                               
  /nix/store/9f9s3shhccfwq02k0splzwmf4awzrs8i-r-RPostgres-1.0-4.drv                                                                                                                            
building '/nix/store/9f9s3shhccfwq02k0splzwmf4awzrs8i-r-RPostgres-1.0-4.drv'...                                                                                                                
unpacking sources                                                                                                                                                                              
unpacking source archive /nix/store/i0i46w7nvbvyxm7kpiacrfqwnp863j3y-RPostgres_1.0-4.tar.gz                                                                                                    
source root is RPostgres                                                                                                                                                                       
setting SOURCE_DATE_EPOCH to timestamp 1513785056 of file RPostgres/MD5                                                                                                                        
patching sources                                                                                                                                                                               
configuring                                                                                                                                                                                    
building                                                                                                                                                                                       
running tests                                                                                                                                                                                  
installing                                                                                                                                                                                     
* installing *source* package 'RPostgres' ...                                                                                                                                                  
** package 'RPostgres' successfully unpacked and MD5 sums checked                                                                                                                              
sh: ./configure: /bin/bash: bad interpreter: No such file or directory                                                                                                                         
ERROR: configuration failed for package 'RPostgres'                                                                                                                                            
* removing '/nix/store/1kcb2fipcp2jsdlj4wbk9p99ddv5r2rg-r-RPostgres-1.0-4/library/RPostgres'                                                                                                   
builder for '/nix/store/9f9s3shhccfwq02k0splzwmf4awzrs8i-r-RPostgres-1.0-4.drv' failed with exit code 1                                                                                        
error: build of '/nix/store/9f9s3shhccfwq02k0splzwmf4awzrs8i-r-RPostgres-1.0-4.drv' failed

cc @peti

ryantm commented 6 years ago

I made a PR to fix it. It builds after this PR. I don't really know how to test it.

ivanbrennan commented 6 years ago

Thanks @ryantm I'm not sure why we ran into different errors, but I was able to successfully build using your fix.

ryantm commented 6 years ago

@ivanbrennan you were probably building on a system where /bin/bash exists

ivanbrennan commented 6 years ago

@ryantm You're exactly right. I was on an Ubuntu system.

logantalley commented 3 years ago

@ryantm I am running into the issue that the merge was supposed to fix. I see that it patches 'configure' and then it complains that the MD5 checksum for 'configure' failed.

building '/nix/store/qkd83fp2b0jw9ba0d73a6p43wkcncyhl-r-RPostgres-1.2.1.drv'...
unpacking sources
unpacking source archive /nix/store/9wz0mzci8l3yhdb9yrd6hz0hpy7gaqwb-RPostgres_1.2.1.tar.gz
source root is RPostgres
setting SOURCE_DATE_EPOCH to timestamp 1601291402 of file RPostgres/MD5
patching sources
configuring
patching script interpreter paths in configure
configure: interpreter directive changed from "#!/bin/sh" to "/nix/store/xvvgw9sb8wk6d2c0j3ybn7sll67s3s4z-bash-4.4-p23/bin/sh"
building
running tests
installing
* installing *source* package 'RPostgres' ...
file 'configure' has the wrong MD5 checksum
** using staged installation
./configure: line 2: /bin/bash: No such file or directory
Warning in system(cmd) : error in running command
ERROR: configuration failed for package 'RPostgres'
* removing '/nix/store/6xmpxxnl030wqbp0glvvd5ar8gv8zh7f-r-RPostgres-1.2.1/library/RPostgres'
builder for '/nix/store/qkd83fp2b0jw9ba0d73a6p43wkcncyhl-r-RPostgres-1.2.1.drv' failed with exit code 1
error: build of '/nix/store/qkd83fp2b0jw9ba0d73a6p43wkcncyhl-r-RPostgres-1.2.1.drv' failed
ryantm commented 3 years ago

@logantalley Could you please say what command you are running and provide information about the system running it (OS, version of nix, etc.)?

logantalley commented 3 years ago

@ryantm Yes, my apologies. Running on NixOS 21.05. The command I used was: nix-shell r-test.nix

r-test.nix contains the following:

with import <nixpkgs> {};

pkgs.mkShell {
  buildInputs = with pkgs; [
    R
    rPackages.glue
    rPackages.RPostgres 
  ];
}
ryantm commented 3 years ago

@logantalley I cannot reproduce this. I took the latest master commit and ran this and it worked:

$ nix --version
nix (Nix) 2.4pre20210601_5985b8b
$ NIX_PATH=nixpkgs=https://github.com/nixos/nixpkgs/archive/c87557a817a.tar.gz nix-shell r-test.nix
logantalley commented 3 years ago

Output of nix --version for me is: nix (Nix) 2.3.15

Edit: OK I ran the exact command that you did at the end there, and it does work. So it looks like the fix does not apply for nix v2.3.15, but will work for 2.4+ at least, and maybe some versions between 2.3.15 and 2.4

logantalley commented 3 years ago

So the latest stable version of nix is 2.3.15. So this package doesn't work on stable, you have to specify a newer version, right? What happens if you try using the stable version of nix?

I just did a sudo nix-channel --update and a sudo nixos-rebuild switch and I still can't build RPostgres on stable.

ryantm commented 3 years ago

Yeah, I don't think it has to do with the version of nix. I can reproduce your error with the latest version of release-21.05.

NIX_PATH=nixpkgs=https://github.com/nixos/nixpkgs/archive/ad6e733d633802620b5eec9be91e837973eac18a.tar.gz nix-shell testr.nix
logantalley commented 3 years ago

Ah I see. OK so this a NixOS issue, not a nixpkgs issue. Thank you very much for your help.

ryantm commented 3 years ago

This can be simplified to:

nix-build https://github.com/nixos/nixpkgs/archive/ad6e733d633802620b5eec9be91e837973eac18a.tar.gz -A rPackages.RPostgres fails and nix-build https://github.com/nixos/nixpkgs/archive/master.tar.gz -A rPackages.RPostgres works

I'm asking on Matrix if people have a suggestion for what happend.