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

dotnet-ef does not work with dotnet enabled #1722

Open
rmarquez-modus opened this issue Feb 12, 2025 · 1 comment
Open

dotnet-ef does not work with dotnet enabled #1722

rmarquez-modus opened this issue Feb 12, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@rmarquez-modus
Copy link

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)

@rmarquez-modus rmarquez-modus added the bug Something isn't working label Feb 12, 2025
@rmarquez-modus
Copy link
Author

Just FYI: A workaround could be to nix profile install nixpkgs#dotnet-ef hoping that having it globally won't bring issues with local version of dotnet. So far has not happen to me.

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

No branches or pull requests

1 participant