Skip to content

dotnet-ef does not work with dotnet enabled #1722

Open
@rmarquez-modus

Description

Describe the bug
dotnet-ef tool cannot be used with dotnet (dotnet ef) when setting languages.dotnet.enable = true;.

It's pretty common to use dotnet-ef in .NET projects to run database migrations (Entity Framework); but for some reason when I try to use dotnet-ef, I get a message that it does not recognize the .NET runtime.

A typical way to install this tool is by running dotnet tool install --global dotnet-ef and export the binary path (export PATH="$PATH:$HOME/.dotnet/tools"). The installation seems to work fine but when I execute it (dotnet-ef --help, for example), I get the error shown.

AFAIK, dotnet-ef is looking for the DOTNET_ROOT env var, which for me is something like /nix/store/kfwdfmi8mw2x71sw9b3snfxr8pd61zv6-dotnet-sdk-wrapped-8.0.404.

Error Message:

You must install .NET to run this application.

App: /Users/robinsonmarquez/.dotnet/tools/dotnet-ef
Architecture: arm64
App host version: 8.0.11
.NET location: Not found

Learn more:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=arm64&rid=osx-arm64&os=osx.15&apphost_version=8.0.11

Expectation

I would expect commands dotnet-ef --help or dotnet ef --help to work correctly by providing the help text.

To reproduce
devenv.nix

{ pkgs, lib, config, inputs, ... }:

{
  #Custom options 
  cachix.enable = false;
  languages.dotnet.enable = true;

  packages = [
    pkgs.dotnet-runtime_8
  ];
  enterShell = ''
    export PATH="$PATH:$HOME/.dotnet/tools"
  '';
}

devenv,yaml

inputs:
  nixpkgs:
    url: github:cachix/devenv-nixpkgs/rolling

devenv.lock

{
  "nodes": {
    "devenv": {
      "locked": {
        "dir": "src/modules",
        "lastModified": 1738232507,
        "owner": "cachix",
        "repo": "devenv",
        "rev": "8b611a15df98b6225eec53be7d24bf39d3ab494d",
        "type": "github"
      },
      "original": {
        "dir": "src/modules",
        "owner": "cachix",
        "repo": "devenv",
        "type": "github"
      }
    },
    "flake-compat": {
      "flake": false,
      "locked": {
        "lastModified": 1733328505,
        "owner": "edolstra",
        "repo": "flake-compat",
        "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
        "type": "github"
      },
      "original": {
        "owner": "edolstra",
        "repo": "flake-compat",
        "type": "github"
      }
    },
    "gitignore": {
      "inputs": {
        "nixpkgs": [
          "pre-commit-hooks",
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1709087332,
        "owner": "hercules-ci",
        "repo": "gitignore.nix",
        "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
        "type": "github"
      },
      "original": {
        "owner": "hercules-ci",
        "repo": "gitignore.nix",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1733477122,
        "owner": "cachix",
        "repo": "devenv-nixpkgs",
        "rev": "7bd9e84d0452f6d2e63b6e6da29fe73fac951857",
        "type": "github"
      },
      "original": {
        "owner": "cachix",
        "ref": "rolling",
        "repo": "devenv-nixpkgs",
        "type": "github"
      }
    },
    "pre-commit-hooks": {
      "inputs": {
        "flake-compat": "flake-compat",
        "gitignore": "gitignore",
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1737465171,
        "owner": "cachix",
        "repo": "pre-commit-hooks.nix",
        "rev": "9364dc02281ce2d37a1f55b6e51f7c0f65a75f17",
        "type": "github"
      },
      "original": {
        "owner": "cachix",
        "repo": "pre-commit-hooks.nix",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "devenv": "devenv",
        "nixpkgs": "nixpkgs",
        "pre-commit-hooks": "pre-commit-hooks"
      }
    }
  },
  "root": "root",
  "version": 7
}

Version
devenv 1.3.1 (aarch64-darwin)

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions