ihp icon indicating copy to clipboard operation
ihp copied to clipboard

ihp-new fails to set up direnv and devenv on macOS

Open salomvary opened this issue 1 year ago • 4 comments

I am going through the Getting Started Guide and ihp-new seems to fail to install direnv:

$ ihp-new blog

DIRENV MISSING
IHP uses direnv to manage env variables.
Learn more about direnv here: https://direnv.net/


We will install direnv for you now. Continue? (Type y to proceed) 
y
Direnv needs to be hooked into your shell.
Would you like to attempt to do this automatically? (Type y to proceed) 
y
Great!
Adding hook to ~/.zshrc...
We will now create your new IHP project. This may take up to 30 seconds.
Initialized empty Git repository in /Users/mrc/Projects/learn-haskell/blog/.git/
Updating build/Generated/Enums.hs
Updating build/Generated/ActualTypes.hs
Updating build/Generated/Types.hs
* Main.hs (import)
* Main.hs (import)
* Main.hs (AddMountToFrontController)
+ Web/Types.hs
+ Web/Routes.hs
+ Web/FrontController.hs
+ Web/Controller/Prelude.hs
+ Web/View/Layout.hs
+ Web/View/Prelude.hs
+ Web/Controller/Static.hs
+ Web/View/Static/Welcome.hs
/nix/store/q5zbyysl4czhbs8lgvqqg885z7431wlq-ihp-new-1.3.0/bin/.ihp-new-wrapped: line 251: direnv: command not found

I've followed the Guide instructions. Enabled the optional Flakes as recommended by the Guide.

ihp-new version: 1.3.0 nix (Nix) 2.24.9 zsh 5.8.1 (x86_64-apple-darwin21.0) macOS 12.7.6

direnv indeed does not seem to be on the path, even in a new terminal window.

The workaround was to install direnv using brew install direnv.

Once I got past this issue, I got to a successful project creation, devenv was missing too:

🚀 Project created, happy coding :)
You can start the server by running:
  cd blog
  devenv up

$ cd blog
$ devenv up
zsh: command not found: devenv

Anyway, as a last desperate attempt, I've removed Nix as described here and re-installed it following the Guide, but skipped the "Optional: Enabling Flakes" step.

Then nix-env --install ihp-new failed with:

$ nix-env --install ihp-new
error: selector 'ihp-new' matches no derivations

At this point I gave up.

salomvary avatar Oct 13 '24 10:10 salomvary

Can you install direnv manually by doing nix profile add nixpkgs#direnv or nix-env --installer ihp-new and after that hook it into your shell manually https://direnv.net/docs/hook.html ?

mpscholten avatar Oct 17 '24 13:10 mpscholten

Running into a similar issue after upgrading to an M4 Mac and trying to transfer my development environment from an old Intel Mac. In my case, I get

error: selector 'ihp-new' matches no derivations

whenever I run nix-env --install ihp-new, whether I enable flakes or not. Did the whole uninstall/reinstall nix routine a few times but haven't figured out what is going wrong.

stephenbenedict avatar Jan 07 '25 14:01 stephenbenedict

Can you try to update the nixpkgs channels:

nix-channel --update nixpkgs

mpscholten avatar Jan 07 '25 14:01 mpscholten

Suddenly it worked. But not sure what change was responsible...

stephenbenedict avatar Jan 15 '25 08:01 stephenbenedict