Skip to content

error: internal error: accessed dependencies from pyproject.nix project, not uv.lock #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
srid opened this issue Mar 28, 2025 · 3 comments · Fixed by #38
Closed

error: internal error: accessed dependencies from pyproject.nix project, not uv.lock #34

srid opened this issue Mar 28, 2025 · 3 comments · Fixed by #38
Labels
bug Something isn't working

Comments

@srid
Copy link

srid commented Mar 28, 2025

description

On NixOS, activating direnv leads to:

Image

environment

I'm on NixOS with Nix 2.24.10. Initiated the template like this:

Image
@srid srid added the bug Something isn't working label Mar 28, 2025
@cameronraysmith
Copy link
Collaborator

cameronraysmith commented Apr 25, 2025

Many thanks for reporting this @srid. We're using a one-line command directly from the README (or with my global om installation locally via om init) which invokes pytest in the devshell with nix develop rather than including direnv allow there

nix --accept-flake-config run github:juspay/omnix -- init github:sciexp/python-nix-template -o pnt-mono --non-interactive --params '{
"package-name-kebab-case": "pnt-mono",
"package-name-snake-case": "pnt_mono",
"monorepo-package": true,
"git-org": "pnt-mono",
"author": "Pnt Mono",
"author-email": "[email protected]",
"vscode": true,
"github-ci": true,
"nix-template": false
}' && \
cd pnt-mono && \
git init && \
git commit --allow-empty -m "initial commit (empty)" && \
git add . && \
nix develop --accept-flake-config -c pytest

Here's the associated CI log:

There are two issues

  1. If you initialize the template for a directory sample, then delete it, and then attempt to initialize the same template in the same directory again, the active direnv state for that directory will not have been revoked (direnv status --> Found RC allowed 0) and will immediately attempt to activate on reentry to that directory. To fix this we need to add a direnv revoke ./sample/ before the command to cd into it to bring the template initialization process closer to precise idempotency. This needs to be updated in the CI template.yaml, README, and in the template welcome message.
  2. When initializing the single-package version of the template with "monorepo-package": false we need to make sure we update the uv.lock file before staging it with git add .

We could use (diff with update on RHS)

om init github:sciexp/python-nix-template -o sample --non-int   om init github:sciexp/python-nix-template -o sample --non-int
   "package-name-kebab-case": "sample",                            "package-name-kebab-case": "sample",
   "package-name-snake-case": "sample",                            "package-name-snake-case": "sample",
   "monorepo-package": false,                                      "monorepo-package": false,
   "git-org": "srid",                                              "git-org": "srid",
   "author": "Srid",                                               "author": "Srid",
   "author-email": "[email protected]",                                 "author-email": "[email protected]",
   "vscode": true,                                                 "vscode": true,
   "github-ci": true,                                              "github-ci": true,
   "nix-template": false                                           "nix-template": false
 }' && \                                                         }' && \
                                                              >  direnv revoke ./sample/ && \
 cd sample && \                                                  cd sample && \
 git init && \                                                   git init && \
 git commit --allow-empty -m "initial commit (empty)" && \       git commit --allow-empty -m "initial commit (empty)" && \
                                                              >  nix run github:NixOS/nixpkgs/nixos-unstable#uv -- lock && \
 git add . && \                                                  git add . && \
 nix develop --accept-flake-config -c pytest                  |  direnv allow && \
                                                              >  eval "$(direnv export $(basename $SHELL))" && \
                                                              >  pytest

but it's a bit ugly and confusing to require the eval and thus seems to make more sense to keep the execution of pytest in the devshell via nix develop

om init github:sciexp/python-nix-template -o sample --non-interactive --params '{
   "package-name-kebab-case": "sample",
   "package-name-snake-case": "sample",
   "monorepo-package": false,
   "git-org": "srid",
   "author": "Srid",
   "author-email": "[email protected]",
   "vscode": true,
   "github-ci": true,
   "nix-template": false
 }' && \
 (command -v direnv >/dev/null 2>&1 && direnv revoke ./sample/ || true) && \
 cd sample && \
 git init && \
 git commit --allow-empty -m "initial commit (empty)" && \
 nix run github:NixOS/nixpkgs/nixos-unstable#uv -- lock && \
 git add . && \
 nix develop --accept-flake-config -c pytest && \
 echo "Run 'direnv allow' to activate the nix devshell with direnv"

and leave it to the user to run direnv allow if they would like to do so.
This version of the command you used addresses both of the issues above.

Added a slightly modified version of this in

@cameronraysmith
Copy link
Collaborator

Incidentally noted potential for confusion regarding the template string replacement of one of the cache names in

when reviewing this.

@cameronraysmith
Copy link
Collaborator

Feel free to reopen if #38 and the discussion above didn't resolve this for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants