Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

GOPATH is incorrectly overriden #23

Closed
mmlb opened this issue Apr 2, 2019 · 3 comments
Closed

GOPATH is incorrectly overriden #23

mmlb opened this issue Apr 2, 2019 · 3 comments
Labels
more data needed Some party needs to provide more information

Comments

@mmlb
Copy link

mmlb commented Apr 2, 2019

I've got GOPATH setup from my default shell, and using direnv's default use_nix my GOPATH is appended to in the resulting env, but with lorri it is replaced.

[manny@manny:~/code/src/github.com/packethost/tinkerbell]$ ls -l ~/.config/direnv/
total 20
drwxr-xr-x 2 manny users   34 Apr  2 14:25 allow
-rw-r--r-- 1 manny users  389 Apr  2 13:12 direnvrc.0
-rw-r--r-- 1 manny users 4017 Mar 19 11:28 direnvrc.old

[manny@manny:~/code/src/github.com/packethost/tinkerbell]$ direnv deny
direnv: error .envrc is blocked. Run `direnv allow` to approve its content.

[manny@manny:~/code/src/github.com/packethost/tinkerbell]$ cd ..
direnv: unloading

[manny@manny:~/code/src/github.com/packethost]$ cd -
/home/manny/code/src/github.com/packethost/tinkerbell
direnv: error .envrc is blocked. Run `direnv allow` to approve its content.

[manny@manny:~/code/src/github.com/packethost/tinkerbell]$ echo $GOPATH
/home/manny/code

[manny@manny:~/code/src/github.com/packethost/tinkerbell]$ echo 'use_nix' > .envrc
direnv: loading .envrc
direnv: export +AR +AR_FOR_TARGET +AS +AS_FOR_TARGET +CC +CC_FOR_TARGET +CONFIG_SHELL +CXX +CXX_FOR_TARGET +HOST_PATH +IN_NIX_SHELL +LD +LD_FOR_TARGET +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_aarch64_unknown_linux_gnu_TARGET_TARGET +NIX_BINTOOLS_WRAPPER_x86_64_unknown_linux_gnu_TARGET_HOST +NIX_BINTOOLS_WRAPPER_x86_64_unknown_linux_gnu_TARGET_TARGET +NIX_BUILD_CORES +NIX_BUILD_TOP +NIX_CC +NIX_CC_WRAPPER_aarch64_unknown_linux_gnu_TARGET_TARGET +NIX_CC_WRAPPER_x86_64_unknown_linux_gnu_TARGET_HOST +NIX_CC_WRAPPER_x86_64_unknown_linux_gnu_TARGET_TARGET +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_INDENT_MAKE +NIX_LDFLAGS +NIX_STORE +NIX_TARGET_BINTOOLS +NIX_TARGET_CC +NIX_TARGET_CFLAGS_COMPILE +NIX_TARGET_LDFLAGS +NM +NM_FOR_TARGET +OBJCOPY +OBJCOPY_FOR_TARGET +OBJDUMP +OBJDUMP_FOR_TARGET +RANLIB +RANLIB_FOR_TARGET +READELF +READELF_FOR_TARGET +SIZE +SIZE_FOR_TARGET +SOURCE_DATE_EPOCH +STRINGS +STRINGS_FOR_TARGET +STRIP +STRIP_FOR_TARGET +TARGET_AR +TARGET_AS +TARGET_CC +TARGET_CXX +TARGET_LD +TARGET_NM +TARGET_OBJCOPY +TARGET_OBJDUMP +TARGET_RANLIB +TARGET_READELF +TARGET_SIZE +TARGET_STRINGS +TARGET_STRIP +TARGET_WINDRES +TEMP +TEMPDIR +TMP +WINDRES +WINDRES_FOR_TARGET +_PATH +buildInputs +builder +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +env +name +nativeBuildInputs +out +outputs +propagatedBuildInputs +propagatedNativeBuildInputs +shell +stdenv +strictDeps +system ~GOPATH ~PATH

[manny@manny:~/code/src/github.com/packethost/tinkerbell]$ echo $GOPATH
/home/manny/code:/nix/store/l6747b8vkpmazcaxm89dd0amky0q35nn-go-1.11/share/go

[manny@manny:~/code/src/github.com/packethost/tinkerbell]$ echo 'eval "$(lorri direnv)"' > .envrc
direnv: error .envrc is blocked. Run `direnv allow` to approve its content.

[manny@manny:~/code/src/github.com/packethost/tinkerbell]$ direnv allow
direnv: loading .envrc
direnv: export +AR +AR_FOR_TARGET +AS +AS_FOR_TARGET +CC +CC_FOR_TARGET +CONFIG_SHELL +CXX +CXX_FOR_TARGET +HOST_PATH +IN_NIX_SHELL +LD +LD_FOR_TARGET +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_aarch64_unknown_linux_gnu_TARGET_TARGET +NIX_BINTOOLS_WRAPPER_x86_64_unknown_linux_gnu_TARGET_HOST +NIX_BINTOOLS_WRAPPER_x86_64_unknown_linux_gnu_TARGET_TARGET +NIX_BUILD_CORES +NIX_BUILD_TOP +NIX_CC +NIX_CC_WRAPPER_aarch64_unknown_linux_gnu_TARGET_TARGET +NIX_CC_WRAPPER_x86_64_unknown_linux_gnu_TARGET_HOST +NIX_CC_WRAPPER_x86_64_unknown_linux_gnu_TARGET_TARGET +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_INDENT_MAKE +NIX_LDFLAGS +NIX_LOG_FD +NIX_STORE +NIX_TARGET_BINTOOLS +NIX_TARGET_CC +NIX_TARGET_CFLAGS_COMPILE +NIX_TARGET_LDFLAGS +NM +NM_FOR_TARGET +OBJCOPY +OBJCOPY_FOR_TARGET +OBJDUMP +OBJDUMP_FOR_TARGET +RANLIB +RANLIB_FOR_TARGET +READELF +READELF_FOR_TARGET +SIZE +SIZE_FOR_TARGET +SOURCE_DATE_EPOCH +STRINGS +STRINGS_FOR_TARGET +STRIP +STRIP_FOR_TARGET +TARGET_AR +TARGET_AS +TARGET_CC +TARGET_CXX +TARGET_LD +TARGET_NM +TARGET_OBJCOPY +TARGET_OBJDUMP +TARGET_RANLIB +TARGET_READELF +TARGET_SIZE +TARGET_STRINGS +TARGET_STRIP +TARGET_WINDRES +WINDRES +WINDRES_FOR_TARGET +_PATH +buildInputs +builder +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +env +name +nativeBuildInputs +origArgs +origBuilder +origPATH +origSystem +out +outputs +propagatedBuildInputs +propagatedNativeBuildInputs +shell +stdenv +strictDeps +system ~GOPATH ~PATH

[manny@manny:~/code/src/github.com/packethost/tinkerbell]$ echo $GOPATH
/nix/store/l6747b8vkpmazcaxm89dd0amky0q35nn-go-1.11/share/go

I see that the generated output of lorri direnv handles PATH as a special variable, should the logic be updated for *PATH or add GOPATH to the list?

@Profpatsch
Copy link
Collaborator

What does your shell.nix look like?

lorri does not run shellHooks at the moment, see #7.

@Profpatsch Profpatsch added the more data needed Some party needs to provide more information label Apr 4, 2019
@mmlb
Copy link
Author

mmlb commented Apr 5, 2019

~/code/src/github.com/packethost/tinkerbell master? *24                                                                                      0.00 20:31:27
❯ tail -n+1 .envrc shell.nix
==> .envrc <==
#OLDGOPATH=$GOPATH
eval "$(lorri direnv)"
#GOPATH=$OLDGOPATH:$GOPATH
#unset OLDGOPATH

==> shell.nix <==
let
  _pkgs = import <nixpkgs> {};
in
{ pkgs ? import (_pkgs.fetchFromGitHub { owner = "NixOS";
                                         repo = "nixpkgs";
                                         rev = "18.09";
                                         sha256 = "1ib96has10v5nr6bzf7v8kw7yzww8zanxgw2qi1ll1sbv6kj6zpd";
                                       }) {}
}:

with pkgs;

stdenv.mkDerivation rec {
  name = "tinkerbell";
  env = buildEnv { name = name; paths = buildInputs; };
  buildInputs = [
    dep
    gcc
    git-lfs
    gnumake
    go
    pkgsCross.aarch64-multiplatform.buildPackages.gcc
    xz
  ];
}

~/code/src/github.com/packethost/tinkerbell master? *24                                                                                      0.00 20:31:53
❯ env | grep GOPATH
GOPATH=/nix/store/l6747b8vkpmazcaxm89dd0amky0q35nn-go-1.11/share/go

@Profpatsch
Copy link
Collaborator

Here is a minimal repro that reproduces the bug you see:

shell.nix:

with import <nixpkgs> {};

stdenv.mkDerivation
{
  name = "tmpshell";
  buildInputs = [ go ];
}

.envrc:

eval "$(lorri direnv)"
$ printenv GOPATH
/home/philip/.go
$ cd repro/
$ direnv allow
direnv: loading .envrc
direnv: export +AR +AS +CC +CONFIG[…snip]
$ printenv GOPATH
/nix/store/barxv95b8arrlh97s6axj8k7ljn7aky1-go-1.12/share/go
$ direnv deny
$ nix-shell
> nix-shell
[nix-shell]$ printenv GOPATH
/home/philip/.go:/nix/store/barxv95b8arrlh97s6axj8k7ljn7aky1-go-1.12/share/go

I think the go derivation has a shellHook (or a similar hook) that sets up the GOPATH for nix-shell. If so, this is a version of #7 indeed, making it a much more pressing feature to implement.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
more data needed Some party needs to provide more information
Projects
None yet
Development

No branches or pull requests

2 participants