Skip to content
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

New project appears to be broken right from the start. #1787

Closed
seanparsons opened this issue Aug 2, 2023 · 16 comments · Fixed by #1898
Closed

New project appears to be broken right from the start. #1787

seanparsons opened this issue Aug 2, 2023 · 16 comments · Fixed by #1898

Comments

@seanparsons
Copy link

seanparsons commented Aug 2, 2023

When I create a new project and try to get it up and running the project just appears to be broken:

sean@tower ~/workspace (master)> ihp-new ihp-test

Direnv shell hook doesn't seem correct.
Direnv needs to be hooked into your shell. Please follow the steps below:
Bash: Add eval "$(direnv hook bash)" to ~/.bashrc
ZSH: Add eval "$(direnv hook zsh)" to ~/.zshrc
Other shells: See https://direnv.net/#README
This could be a false negative if you use a more complex shell profile

We will now create your new IHP project. This may take up to 30 seconds.
warning: Pathname can't be converted from UTF-8 to current locale.
error: getting status of '/nix/store/h8c7bnrnldxyi94hvmslxid9k87x7yid-source/workspace/ihp-test': No such file or directory


sean@tower ~/workspace (master)> cd ihp-test/
direnv: loading ~/workspace/ihp-test/.envrc
direnv: loading https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc (sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=)
direnv: using flake . --impure --accept-flake-config
error: getting status of '/nix/store/h8c7bnrnldxyi94hvmslxid9k87x7yid-source/workspace/ihp-test': No such file or directory
error: getting status of '/home/sean/workspace/ihp-test/.direnv/flake-profile.1771549': No such file or directory
error: getting status of '/nix/store/h8c7bnrnldxyi94hvmslxid9k87x7yid-source/workspace/ihp-test': No such file or directory
direnv: nix-direnv: renewed cache
direnv: export ~XDG_DATA_DIRS


sean@tower ~/w/ihp-test (master)> git init .
Initialized empty Git repository in /home/sean/workspace/ihp-test/.git/


sean@tower ~/w/ihp-test (trunk)> direnv allow
direnv: loading ~/workspace/ihp-test/.envrc
direnv: loading https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc (sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=)
direnv: using flake . --impure --accept-flake-config
warning: Git tree '/home/sean/workspace/ihp-test' is dirty
error: getting status of '/nix/store/0ccnxa25whszw7mgbgyzdm4nqc0zwnm8-source/flake.nix': No such file or directory
error: getting status of '/home/sean/workspace/ihp-test/.direnv/flake-profile.1771721': No such file or directory
warning: Git tree '/home/sean/workspace/ihp-test' is dirty
error: getting status of '/nix/store/0ccnxa25whszw7mgbgyzdm4nqc0zwnm8-source/flake.nix': No such file or directory
direnv: nix-direnv: renewed cache
direnv: export ~XDG_DATA_DIRS


sean@tower ~/w/ihp-test (trunk)> ./start
File devenv.nix does not exist. To get started, run:

  $ devenv init
sean@tower ~/w/ihp-test (trunk)> 

The direnv errors I don't believe to be an issue as I'm using Fish and I've used direnv for a few years with it without any problems. But the error: getting status of ... messages seem to be the cause of the environment not loading properly. I have played with IHP 1.0 just after release on this machine and it worked fine, I'm just coming back to it now thinking about using it for a real project.

Assorted system info:

- system: `"x86_64-linux"`
 - host os: `Linux 6.1.38, NixOS, 23.05 (Stoat), 23.05.1981.9fdfaeb7b96`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - channels(sean): `""`
 - channels(root): `"nixos-23.05, nixos-hardware"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@mpscholten
Copy link
Member

Can you install the latest version of ihp-new via nix-env -f https://downloads.digitallyinduced.com/ihp-new.tar.gz -i ihp-new ?

@seanparsons
Copy link
Author

That's basically what I did before although I had a system installed version from nixpkgs. I made sure to remove the system installed version and tried again and got exactly the same results.

@mpscholten
Copy link
Member

Strange. Is your direnv version up to date? Maybe you can also run the auto trobuelshooting script https://ihp.digitallyinduced.com/Guide/troubleshooting.html

@seanparsons
Copy link
Author

Auto troubleshooting script gives me this:

sean@tower ~/w/ihp-test (trunk)> curl --silent https://raw.githubusercontent.com/digitallyinduced/ihp/master/Troubleshoot/ihp-troubleshoot | python3
Checking that the current directory is an IHP project:
+ Found Main.hs
+ Found start script
+ Installed Nix version 2.13.3 is 2.4 or later
Checking direnv:
+ Found .envrc
+ direnv loads .envrc
+ direnv allows .envrc
- ghci is not loaded from /nix/store/... Is direnv hooked into your shell?
Checking .ghci:
+ Found .ghci
Traceback (most recent call last):
  File "<stdin>", line 168, in <module>
  File "<stdin>", line 68, in run_command
  File "/nix/store/a5k7x5mn7i7rcji4n99mwiqhmgjdzxmk-python3-3.10.12/lib/python3.10/subprocess.py", line 503, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/nix/store/a5k7x5mn7i7rcji4n99mwiqhmgjdzxmk-python3-3.10.12/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/nix/store/a5k7x5mn7i7rcji4n99mwiqhmgjdzxmk-python3-3.10.12/lib/python3.10/subprocess.py", line 1863, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ghci'

I realised that I had a custom .direnvrc and disabled that to no effect.

sean@tower ~ (master)> direnv --version
2.32.2

@mpscholten
Copy link
Member

Checking direnv:
+ Found .envrc
+ direnv loads .envrc
+ direnv allows .envrc
- ghci is not loaded from /nix/store/... Is direnv hooked into your shell?

This is very strange. Direnv is correctly loaded, but it's not finding ghci.

Can you run direnv status from within the project directory?

@seanparsons
Copy link
Author

sean@tower ~/w/ihp-test (trunk)> direnv status
direnv exec path /nix/store/3r10fc6scpmivjyw7i7gbpgcxkywacmr-direnv-2.32.2/bin/direnv
DIRENV_CONFIG /home/sean/.config/direnv
bash_path /nix/store/8fv91097mbh5049i9rglc73dx6kjg3qk-bash-5.2-p15/bin/bash
disable_stdin false
warn_timeout 5s
whitelist.prefix []
whitelist.exact map[]
Loaded RC path /home/sean/workspace/ihp-test/.envrc
Loaded watch: ".envrc" - 2023-08-07T22:25:34+01:00
Loaded watch: "../../.local/share/direnv/allow/771e9457960d7b2ad5eb553da6553eaf0d5ad3eb6159ffb48c6507011cab2334" - 2023-08-07T22:43:45+01:00
Loaded watch: "../../.direnvrc" - 1970-01-01T01:00:00+01:00
Loaded watch: "../../.config/direnv/direnvrc" - 1970-01-01T01:00:00+01:00
Loaded watch: "flake.nix" - 2023-08-07T22:25:34+01:00
Loaded watch: "flake.lock" - 2023-08-07T22:25:34+01:00
Loaded watch: "devshell.toml" - 1970-01-01T01:00:00+01:00
Loaded RC allowed false
Loaded RC allowPath 
Found RC path /home/sean/workspace/ihp-test/.envrc
Found watch: ".envrc" - 2023-08-07T22:25:34+01:00
Found watch: "../../.local/share/direnv/allow/771e9457960d7b2ad5eb553da6553eaf0d5ad3eb6159ffb48c6507011cab2334" - 2023-08-07T22:43:45+01:00
Found RC allowed true
Found RC allowPath /home/sean/.local/share/direnv/allow/771e9457960d7b2ad5eb553da6553eaf0d5ad3eb6159ffb48c6507011cab2334

@Meptl
Copy link

Meptl commented Aug 22, 2023

I was having similar issues. It seems like ihp-new doesn't work when run in an existing direnv or perhaps doesn't play well with nix-direnv's autoloading. I was able to resolve my issue by installing the packages at the system level (NixOS), so something like:

  environment.systemPackages = with pkgs; [
    cabal-install ghc ihp-new cachix gnumake
  ];

in configuration.nix. Unideal but I was able to ihp-new blog without errors. My system information outside of direnv (Haskell version will differ from project-specific package version):

~ $ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.4.6
~ $ direnv --version
2.32.3
~ $ uname -a
Linux fume 6.4.8 #1-NixOS SMP PREEMPT_DYNAMIC Thu Aug  3 08:26:15 UTC 2023 x86_64 GNU/Linux
~ $ ihp-new --version

ihp-new version: 1.3.0
~ $ nix --version
nix (Nix) 2.17.0
~ $ nixos-version
23.11.20230817.c2f3ec7 (Tapir)

@janat08
Copy link

janat08 commented Sep 2, 2023

I wound up trying ihp-new in VM after WSL assuming that it doesn't ship broken. Is there a way to ihp-new with v1, with the assumptiong that migrating would be easy enough?

@seanparsons
Copy link
Author

seanparsons commented Sep 21, 2023

So this is definitely broken in general as far as I can tell, as I've just built a completely fresh machine and I get the same kind of output:

sean@laptop ~ (master)> nix-env -f https://downloads.digitallyinduced.com/ihp-new.tar.gz -i ihp-new
installing 'ihp-new'
this derivation will be built:
  /nix/store/6shfgb2dkypirlpdf9z1wsczwsppqkxa-ihp-new.drv
building '/nix/store/6shfgb2dkypirlpdf9z1wsczwsppqkxa-ihp-new.drv'...
unpacking sources
unpacking source archive /nix/store/082fg2nvbizmjn6gcpr291my5r35wssg-qazz4dvqasa1rq2gd6g235bli4pxs8rr-source
source root is qazz4dvqasa1rq2gd6g235bli4pxs8rr-source
patching sources
configuring
no configure script, doing nothing
building
no Makefile or custom buildPhase, doing nothing
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/41gn9x9lnqm4ag05lc0zg0zairlhhyg4-ihp-new
checking for references to /build/ in /nix/store/41gn9x9lnqm4ag05lc0zg0zairlhhyg4-ihp-new...
patching script interpreter paths in /nix/store/41gn9x9lnqm4ag05lc0zg0zairlhhyg4-ihp-new
/nix/store/41gn9x9lnqm4ag05lc0zg0zairlhhyg4-ihp-new/ihp-new: interpreter directive changed from "#!/usr/bin/env bash" to "/nix/store/8fv91097mbh5049i9rglc73dx6kjg3qk-bash-5.2-p15/bin/bash"
stripping (with command strip and flags -S -p) in  /nix/store/41gn9x9lnqm4ag05lc0zg0zairlhhyg4-ihp-new/bin
building '/nix/store/xd5blapks5glica6b4wq40pj0bb3i872-user-environment.drv'...
sean@laptop ~ (master)> ihp-new --version

ihp-new version: 1.3.0
sean@laptop ~ (master)> cd workspace/
sean@laptop ~/workspace (master)> ihp-new ihp-test

Direnv shell hook doesn't seem correct.
Direnv needs to be hooked into your shell. Please follow the steps below:
Bash: Add eval "$(direnv hook bash)" to ~/.bashrc
ZSH: Add eval "$(direnv hook zsh)" to ~/.zshrc
Other shells: See https://direnv.net/#README
This could be a false negative if you use a more complex shell profile

Cachix doesn't seem to be configured
IHP provides a cachix cache with binaries for all IHP packages and commonly used dependencies.
While not required, this greatly speeds up the installation & build process.
This could be a false negative if you use a more complex nix configuration.


We will configure the cache for you now using 'cachix use digitallyinduced'. Continue? (Type y to proceed) 
y
Configured https://digitallyinduced.cachix.org binary cache in /home/sean/.config/nix/nix.conf
We will now create your new IHP project. This may take up to 30 seconds.

warning: Pathname can't be converted from UTF-8 to current locale.
error: getting status of '/nix/store/r616flql2wdmcgyky01wiwrqp9mbpim3-source/workspace/ihp-test': No such file or directory
sean@laptop ~/workspace (master)> 
sean@laptop ~/workspace (master)> cd ihp-test/
direnv: error /home/sean/workspace/ihp-test/.envrc is blocked. Run `direnv allow` to approve its content
sean@laptop ~/w/ihp-test (master)> direnv allow
direnv: loading ~/workspace/ihp-test/.envrc
direnv: loading https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc (sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=)
direnv: using flake . --impure --accept-flake-config
error: getting status of '/nix/store/r616flql2wdmcgyky01wiwrqp9mbpim3-source/workspace/ihp-test': No such file or directory
error: getting status of '/home/sean/workspace/ihp-test/.direnv/flake-profile.742787': No such file or directory
error: getting status of '/nix/store/r616flql2wdmcgyky01wiwrqp9mbpim3-source/workspace/ihp-test': No such file or directory
direnv: nix-direnv: renewed cache
direnv: export ~XDG_DATA_DIRS

This is using an almost identical config to the machine I got the previous output on, but it has never had IHP installed on it ever at all prior to what I've just run.

@seanparsons
Copy link
Author

I spent a bit of time this morning and managed to figure out the issue.

I'm not sure if this is something that has changed in more recent versions of nix, but by creating a git repository at the root of the project and git adding everything in the directory makes the nix flake commands suddenly recognise the content correctly.

You can see someone referencing this issue here: https://discourse.nixos.org/t/nix-flakes-nix-store-source-no-such-file-or-directory/17836/12

@mpscholten
Copy link
Member

That makes sense. That's default behaviour in nix flakes.

In your initial bug report at the top you have a line sean@tower ~/workspace (master)> ihp-new ihp-test. The (master) there indicates that your current working directory is in some git repo. Likely this caused nix to not pick up the files.

We should extend ihp-new to error when it's run from some existing git repo

@seanparsons
Copy link
Author

Yup my home folder is a git-annex repo, so that explains that side of it.

Be handy if it was possible to limit how far up the hierarchy nix flakes looks. But I can imagine that might involve changing nix itself.

@mpscholten
Copy link
Member

Yeah, i think that's unlikely to get changed in nix as this could have unintended side effects (e.g. large repos with deep directory hierarchies)

@seanparsons
Copy link
Author

We should extend ihp-new to error when it's run from some existing git repo

Is there a workaround to that though? Much as some kind of informative error is an improvement, if it just prevents people from creating a project then people in my situation are kinda stuck.

@mpscholten
Copy link
Member

Found a better way: We run git init in the project directory by default (and then git add .). Pushed the changes to #1898

@seanparsons
Copy link
Author

seanparsons commented Jan 23, 2024

Found a better way: We run git init in the project directory by default (and then git add .). Pushed the changes to #1898

Yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants