[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ob-sql is not finding psql when using direnv+guix
From: |
Adolfo De Unanue |
Subject: |
Re: ob-sql is not finding psql when using direnv+guix |
Date: |
Tue, 11 May 2021 15:54:15 -0500 |
User-agent: |
Cyrus-JMAP/3.5.0-alpha0-448-gae190416c7-fm-20210505.004-gae190416 |
Dear Malcom
On Mon, May 10, 2021, at 13:14, Cook, Malcolm wrote:
> >I am using Guix with direnv.
>
> What is your shell?
>
My shell is bash, originally I was using zsh and I thought that was the
problem, so I switched to bash and still not working.
> How/When do you "hook direnv into your shell" (https://direnv.net/)?
>
In the .profile file, at login.
> > In an specific folder I am installing and using psql and postgresql using
> > direnv+guix as follows:
> >use guix --manifest=cdpp-manifest.scm
> >
> >export PGUSER=food_user
> >export PGPASSWORD=some_password
> >export PGDATABASE=food
> >
> >layout postgres
>
> When are you doing this?
>
> a) in the "specific folder"'s .envrc file?
> b) in an org-mode shell block that you execute prior to the sql block?
> c) ??
>
>
Option (a)
> You seem to be following [Per\-project
> Postgres](https://jamey.thesharps.us/2019/05/29/per-project-postgres/)
> but with guix instead of nix. Nice.
>
Yep, great post. direnv + guix change the way I develop software, do data
science and write lectures and papers.
> If you enter the directory and then call emacs, earthing should just
> work, no changes neede.
>
It works for almost everything (sql-buffers, python buffers, etc), except for
org-babel sql blocks.
I am using EXWM, so emacs is always on.
> If you want to tell emacs to adopt the environment established by a
> .direnv, you probably want [direnv integration for
> emacs\.](https://github.com/wbolster/emacs-direnv)
>
emacs-direnv was my first choice, but then I changed to envrc
(https://github.com/purcell/envrc) . In both I got the error.
> I've got to try this!
>
> Cheers
>
Please tell me how that works for you
Thanks
- A
> >
> >
> >Where cdpp-manifest.scm contains the following:
> >
> >(specifications->manifest
> >'("python"
> > "python-pandas"
> > "python-numpy"
> > "python-flask"
> > "python-graphene"
> > "postgresql"
> > "jupyter"))
> >
> >I am able to use sql-mode and run queries against the database, in order to
> >achieve that I am using the following .dir-locals.el
> >
> >;;; Directory Local Variables
> >;;; For more information see (info "(emacs) Directory Variables")
> >
> >
> >((nil .
> > ((projectile-project-test-cmd . "pytest --color=no --failed-first
> >--maxfail=5")))
> >(python-mode .
> > ((python-shell-buffer-name . "Python [CDPP-Inspecciones]")))
> >
> >(org-mode . (
> > (indent-tabs-mode . nil)
> > (org-src-preserve-indentation . t)
> > (org-footnote-auto-adjust . t)
> > (org-footnote-auto-label . t)
> > (ispell-local-dictionary . "spanish")
> > (org-export-allow-bind-keywords . t)
> > (org-footnote-define-inline . nil)
> > (org-footnote-section . "Footnotes")))
> >
> >(sql-mode . ((sql-connection-alist . ((mydb
> > (sql-product 'postgres)
> > (sql-database "mydb")
> > (sql-user "db_user")
> > (sql-server (expand-file-name
> >".direnv/postgres"))
> > (sql-port 5432)
> > )
> > )))))
> >
> >But If I try to use an sql org-babel block
> >
> >#+begin_src sql
> >select 1;
> >#+end_src
> >
> >(I am setting the connection variables in a PROPERTY)
> >
> >I get the error: `psql is not found`
> >
> >
> >I was reading about the variable sql-postgres-program, so if I set the
> >following in dir-locals.el
> >
> >(sql-postgres-program .
> >"/gnu/store/f2v92bkx2vfzmkl14qxj3hlmby4dy9x0-profile/bin/psql")
> >
> >It works (note that psql ONLY lives inside the profile defined by
> >direnv+guix), but I don't like the idea of hardcode the path.
> >
> >Is there a better way?
> >
> >Ideally I will expect that the org block will read it from the environment,
> >but is not working.
> >
> >Thanks in advance
> >
>
- ob-sql is not finding psql when using direnv+guix, Adolfo De Unanue, 2021/05/09
- RE: ob-sql is not finding psql when using direnv+guix, Cook, Malcolm, 2021/05/10
- Re: ob-sql is not finding psql when using direnv+guix,
Adolfo De Unanue <=
- RE: ob-sql is not finding psql when using direnv+guix, Cook, Malcolm, 2021/05/12
- org-babel not finding executables when using direnv [Was: Re: ob-sql is not finding psql when using direnv+guix], Adolfo De Unanue, 2021/05/13
- RE: org-babel not finding executables when using direnv [Was: Re: ob-sql is not finding psql when using direnv+guix], Cook, Malcolm, 2021/05/13
- Re: org-babel not finding executables when using direnv [Was: Re: ob-sql is not finding psql when using direnv+guix], Tim Cross, 2021/05/13