I’m setting up a rails app and want to use Postgresql locally.
I have installed the following in my config:
environment.systemPackages = with pkgs; [
ruby_3_3 rubyPackages_3_3.railties postgresql_15
];
services.postgresql =
{ enable = true;
ensureDatabases = [ "mydatabase" ];
authentication = pkgs.lib.mkOverride 10 ''
#type database DBuser auth-method
local all all trust
'';
};
I add gem 'pg' to my Gemfile and run bundle install, but get the following error:
Using libpq from /nix/store/vck707ss9ihj3ygn183mlp8kl525xdm9-postgresql-15.7-lib/lib
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*****************************************************************************
Unable to find PostgreSQL client library.
Please install libpq or postgresql client package like so:
sudo apt install libpq-dev
sudo yum install postgresql-devel
sudo zypper in postgresql-devel
sudo pacman -S postgresql-libs
So I’m trying to install libpq, but nothing I’ve found will get me past this error.
I’ve tried: libpqxx haskellPackages.postgresql-libpq postgresql.lib pkg-config, but I always get stuck at this error.
Can anyone give me pointers for where I might be going wrong?
$ nix-shell
$ gem install --user-install pg
Fetching pg-1.5.6.gem
WARNING: You don't have /home/user/.local/share/gem/ruby/3.1.0/bin in your PATH,
gem executables will not run.
Building native extensions. This could take a while...
Successfully installed pg-1.5.6
Parsing documentation for pg-1.5.6
Installing ri documentation for pg-1.5.6
Done installing documentation for pg after 4 seconds
1 gem installed
Hi, a bit off topic but I just tried devenv.sh to run a rails project locally and it’s awesome, you end with a devenv up command similar to docker compose that starts all processes/services, and the whole config is very minimal, here’s mine: