direnv: error unmarshal() base64 decoding: illegal base64 data at input byte 0

Created on 15 Sep 2019  路  8Comments  路  Source: direnv/direnv

Describe the bug
install on zsh using brew. follow along setup commands. get error.

To Reproduce
install direnv with brew
follow https://direnv.net/#quick-demo up to allow step
after allow see error

Expected behavior
expected env to be read without errors

Environment

  • OS: macos 10.14.6 18g95
  • Shell: zsh 5.7.1 (x86_64-apple-darwin18.2.0)
  • Direnv version direnv: stable 2.20.1

Additional context

cd app
direnv: loading .envrc
direnv: error unmarshal() base64 decoding: illegal base64 data at input byte 0
Bug

Most helpful comment

Ran into the same error message. In my case, I've boiled it down to the following example, where even redirecting stdout doesn't help:

cat >shell.nix <<EOF
{ pkgs ? import <nixpkgs> {}}:
with pkgs;
mkShell {
  shellHook = ''
      echo "["
  '';
}
EOF
cat >.envrc <<EOF
use nix >/dev/null
EOF
direnv allow .

This gives me:

direnv: loading .envrc                                                                                                                                                                                                                                                           
direnv: using nix
direnv: error unmarshal() base64 decoding: illegal base64 data at input byte 0

I guess use_nix gets confused by the echo in the shellHook.

Using direnv-2.20.1, on nixos 19.09

All 8 comments

Really not sure what I did wrong, any help is appreciated. Just followed along setup to the letter.

I suspect that the content of your .envrc is echo export FOO=foo instead of export FOO=foo.

direnv is using stdout to capture the sub-process environment, diff and translate it to your shell. It really should be fixed.

If you have any commands sending outputs in the sub-shell, append >&2 to the line to send it to stderr.

Ran into the same error message. In my case, I've boiled it down to the following example, where even redirecting stdout doesn't help:

cat >shell.nix <<EOF
{ pkgs ? import <nixpkgs> {}}:
with pkgs;
mkShell {
  shellHook = ''
      echo "["
  '';
}
EOF
cat >.envrc <<EOF
use nix >/dev/null
EOF
direnv allow .

This gives me:

direnv: loading .envrc                                                                                                                                                                                                                                                           
direnv: using nix
direnv: error unmarshal() base64 decoding: illegal base64 data at input byte 0

I guess use_nix gets confused by the echo in the shellHook.

Using direnv-2.20.1, on nixos 19.09

Same problem here.

https://github.com/amotus/nixos-sf-atlassian-tools/blob/master/.envrc

Workaround is to 2>&1 use nix | head -n -1 (removing last line from combined output) or removing all outputs from both stdout and stderr: &>/dev/null use nix.

Doing either 2>&1 use nix | head -n -0 or use nix | head -n -1 won't fix the problem.

Using pypi2nix. Using use nix, output is:

$ direnv allow
direnv: loading .envrc
direnv: using nix
warning: ignoring the user-specified setting 'show-trace', because it is a restricted setting and you are not a trusted user
Obtaining file:///home/rgauthier/dev/zilia-ocular/nixos-sf-atlassian-tools
Requirement already satisfied: atlassian-python-api in /nix/store/4m9c3zlya9hixz7wxc8hj665mi31205n-python3.7-atlassian-python-api-1.14.8/lib/python3.7/site-packages (from nixos-sf-atlassian-tools==0.0.0) (1.14.8)
Requirement already satisfied: click in /nix/store/yp0r02j3mnq0pvkd8gb9h8cm58fkc62x-python3.7-click-7.0/lib/python3.7/site-packages (from nixos-sf-atlassian-tools==0.0.0) (7.0)
Requirement already satisfied: requests in /nix/store/0p1ndwiiawl8rwqwwjd8yq21rblhwcm4-python3.7-requests-2.22.0/lib/python3.7/site-packages (from atlassian-python-api->nixos-sf-atlassian-tools==0.0.0) (2.22.0)
Requirement already satisfied: six in /nix/store/w4d1s7p6xhhdxjlj2rsczj18srhpxrvl-python3.7-six-1.13.0/lib/python3.7/site-packages (from atlassian-python-api->nixos-sf-atlassian-tools==0.0.0) (1.13.0)
Requirement already satisfied: requests-oauthlib in /nix/store/pvn7nkq78ng871v98rh62niacphl06vp-python3.7-requests-oauthlib-1.3.0/lib/python3.7/site-packages (from atlassian-python-api->nixos-sf-atlassian-tools==0.0.0) (1.3.0)
Requirement already satisfied: oauthlib in /nix/store/f4phq3q68wkpcwrs4c0bjyn2p8sd5w12-python3.7-oauthlib-3.1.0/lib/python3.7/site-packages (from atlassian-python-api->nixos-sf-atlassian-tools==0.0.0) (3.1.0)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /nix/store/l6xd4c1hxdw510hq0i31dhnrr2fhv1lj-python3.7-chardet-3.0.4/lib/python3.7/site-packages (from requests->atlassian-python-api->nixos-sf-atlassian-tools==0.0.0) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /nix/store/jdvxwn2kwyvavmawpvcg6zjbpxsqys2n-python3.7-urllib3-1.25.7/lib/python3.7/site-packages (from requests->atlassian-python-api->nixos-sf-atlassian-tools==0.0.0) (1.25.7)
Requirement already satisfied: certifi>=2017.4.17 in /nix/store/79ykp4nmcab832zwmhlk244inw4b6v0m-python3.7-certifi-2019.11.28/lib/python3.7/site-packages (from requests->atlassian-python-api->nixos-sf-atlassian-tools==0.0.0) (2019.11.28)
Requirement already satisfied: idna<2.9,>=2.5 in /nix/store/cjc10xmv141b9dvsfqadbim013981hzx-python3.7-idna-2.8/lib/python3.7/site-packages (from requests->atlassian-python-api->nixos-sf-atlassian-tools==0.0.0) (2.8)
Installing collected packages: nixos-sf-atlassian-tools
  Running setup.py develop for nixos-sf-atlassian-tools
Successfully installed nixos-sf-atlassian-tools
WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
direnv: error unmarshal() base64 decoding: illegal base64 data at input byte 8

The last 2 lines are colored yellow.

EDIT

I noticed that these workaround just get rid of the error message and the environment is not loaded. So still looking for a proper workaround.

It seems that all python derivation hooks output to stdout:

pkgs/development/interpreters/python/hooks.

Should these be fixed in nixpkgs or is there a viable alternative?

Direnv 2.20.1, ZSH 5.7.1, NixOS 19.09 at NixOS/nixpkgs@5dc4d071ffecec62588e3c0f58fc38888f24215a.

@jcpetruzza I can't replicate your issue.

shell output

位 direnv --version
2.20.1
位 cat >shell.nix <<EOF
{ pkgs ? import <nixpkgs> {}}:
with pkgs;
mkShell {
  shellHook = ''
      echo "["
  '';
}
EOF
cat >.envrc <<EOF
use nix >/dev/null
EOF
direnv allow .
direnv: loading .envrc
direnv: using nix
direnv: use nix: deriving new environment
direnv: use nix: updating cache
/yl/.direnvrc: line 85: [: missing `]'
direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +HOST_PATH +IN_NIX_SHELL +LD +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_x86_64_unknown_linux_gnu_TARGET_HOST +NIX_BUILD_CORES +NIX_BUILD_TOP +NIX_CC +NIX_CC_WRAPPER_x86_64_unknown_linux_gnu_TARGET_HOST +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_INDENT_MAKE +NIX_LDFLAGS +NIX_SSL_CERT_FILE +NIX_STORE +NM +OBJCOPY +OBJDUMP +RANLIB +READELF +SIZE +SOURCE_DATE_EPOCH +SSL_CERT_FILE +STRINGS +STRIP +TEMP +TEMPDIR +TMP +TMPDIR +__ETC_PROFILE_SOURCED +buildInputs +builder +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +name +nativeBuildInputs +nobuildPhase +out +outputs +patches +phases +propagatedBuildInputs +propagatedNativeBuildInputs +stdenv +strictDeps +system ~PATH

@jraygauthier I was able to reproduce your issue. The problem is that you're building the package directly. If you wrap the package with an mkShell it should work. I'm not sure why that's that though. This patch works for me:

patch to fix shell.nix

diff --git a/shell.nix b/shell.nix
index 57a3544..0009985 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,6 +1,15 @@
 { nixpkgs ? import ./.nix/pinned-nixpkgs.nix {} }:

-nixpkgs.callPackage ./. {
-  inherit nixpkgs;
-  fromNixShell = true;
-}
\ No newline at end of file
+with nixpkgs;
+
+let
+  app = callPackage ./. {
+    inherit nixpkgs;
+    fromNixShell = true;
+  };
+in mkShell {
+  name = "nixos-sf-atlassian-tools";
+  buildInputs = [
+    app
+  ];
+}

TIP: Check out https://github.com/hercules-ci/gitignore.nix, I use it to filter out ./. of everything ignored by Git.

this issue will be fixed in the next release of direnv (see #551)

Nice, thank you @zimbatm .

Was this page helpful?
0 / 5 - 0 ratings