node2nix icon indicating copy to clipboard operation
node2nix copied to clipboard

"EACCES: permission denied" with Gatsby project

Open aidalgol opened this issue 3 years ago • 0 comments

gatsby subcommands fail with a permission error when trying to operate on files under .cache in the project directory under a development nix shell.

  • Clone netlify-templates/gatsby-starter-netlify-cms
  • Run node2nix --development -14 -l
  • Create override.nix with the below contents. (This includes required build dependencies not explicitly declared in package.json.)
  • Run nix-shell -A shell override.nix
  • (Within the nix shell) Run gatsby develop
  • This command will fail with the error Failed to remove .cache files. EACCES: permission denied, unlink /path/to/gatsby-starter-netlify-cms/.cache/ssr-builtin-trackers/tracking-unsafe-module-wrapper.js
override.nix
{ pkgs ? import <nixpkgs> { inherit system; }, system ? builtins.currentSystem
}:

let nodePackages = import ./default.nix { inherit pkgs system; };
in nodePackages // {
  shell = nodePackages.shell.override {
    buildInputs = [
      pkgs.nodePackages.node-gyp-build
      pkgs.pkgconfig
      pkgs.vips
      pkgs.glib
    ];
    preRebuild = ''
      sed -i -e "s|#!/usr/bin/env node|#! ${pkgs.nodejs}/bin/node|" node_modules/node-gyp-build/bin.js
    '';
    shellHook = ''
      ln -sf $NODE_PATH node_modules
    '';
  };
}

aidalgol avatar Feb 25 '22 18:02 aidalgol