-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
direnvrc: eval: <line-number>: syntax error near unexpected token `;' #473
Comments
cc: @simonzkl, just read your comment, and sounds possibly related? |
I don't think this is related. It kinda sounds like zsh executing a bash script or something like that. |
FWIW, this is the contents of our $ cat ~/projects/terraform/.envrc
use flake |
I instructed one of our users to He now is seeing this error: <username>@MacBook-Pro-2 ~ % cd src/freelancing/<company>/terraform/live/apollo/us-east-1/transfer/eff-sftp-out/
direnv: loading ~/src/freelancing/<company>/terraform/.envrc
direnv: using flake
/Users/<username>/.nix-profile/share/nix-direnv/direnvrc: line 211: local: -n: invalid option
local: usage: local name[=value] ...
warning: unknown setting 'upgrade-nix-store-path-url'
evaluating derivation 'git+file:///Users/<username>/src/freelancing/<company>/terraform#devShells.x86_64-darwin.default'direnv: ([/usr/local/bin/direnv export zsh]) is taking a while to execute. Use CTRL-C to give up.
warning: unknown setting 'upgrade-nix-store-path-url'
warning: unknown setting 'upgrade-nix-store-path-url'
warning: unknown setting 'upgrade-nix-store-path-url'
warning: unknown setting 'upgrade-nix-store-path-url'
warning: unknown setting 'upgrade-nix-store-path-url'
warning: unknown setting 'upgrade-nix-store-path-url'
direnv: nix-direnv: renewed cache
/Users/<username>/.nix-profile/share/nix-direnv/direnvrc: eval:1881: syntax error near unexpected token `;'
/Users/<username>/.nix-profile/share/nix-direnv/direnvrc: eval:1881: ` ;&'
direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +DETERMINISTIC_BUILD +HOST_PATH +IN_NIX_SHELL +LD +LD_DYLD_PATH +MACOSX_DEPLOYMENT_TARGET +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_apple_darwin +NIX_BUILD_CORES +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_apple_darwin +NIX_CFLAGS_COMPILE +NIX_DONT_SET_RPATH +NIX_DONT_SET_RPATH_FOR_BUILD +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_IGNORE_LD_THROUGH_GCC +NIX_LDFLAGS +NIX_NO_SELF_RPATH +NIX_STORE +NM +PATH_LOCALE +PYTHONHASHSEED +PYTHONNOUSERSITE +PYTHONPATH +RANLIB +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +ZERO_AR_DATE +__darwinAllowLocalNetworking +__impureHostDeps +__propagatedImpureHostDeps +__propagatedSandboxProfile +__sandboxProfile +__structuredAttrs +buildInputs +buildPhase +builder +cmakeFlags +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +dontAddDisableDepTrack +mesonFlags +name +nativeBuildInputs +out +outputs +patches +phases +preferLocalBuild +propagatedBuildInputs +propagatedNativeBuildInputs +shell +shellHook +stdenv +strictDeps +system ~PATH The |
What bash version are you using? |
I'm instructing users to report their shell (I'm pretty sure we all use I'm also having folks try a bash shell with Nix via: $ echo 'eval "$(direnv hook bash)"' >>~/.bashrc
$ nix run nixpkgs#bash
$ cd <our-project-directory>
$ direnv allow I will report back when I have the results. |
It's also fine to use zsh as the interactive. It's about the version of bash in $PATH (nix-shell -b bash) Even if you zsh as your shell, direnv will use bash internally to evaluate .envrc |
On my system
Also:
Since they're all macOS users, I suspect something similar. I also have nix-darwin installed and installed direnv/nix-direnv with home-manager. So maybe that's why I'm not encountering any issues? |
There is actually a version check that should fail loudly if someone is using an too old bash version. Not sure why this check is not working properly. Otherwise you will need at least bash4. If you use install nix-direnv via home-manager that should already make sure that a new version of bash is put in place. Actually it's enough to install direnv via nix because nix in nixpkgs hardcode the version of bash used. |
From one of our users:
|
So I think this means that our suggestion of installing direnv from Homebrew (in the README) is inappropriate and needs to be re-written? I think the new suggestion should simply be to install ➜ nix shell nixpkgs#direnv
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
bash-3.2$ direnv exec . which -a bash
direnv: loading ~/code/personal/nix-direnv/.envrc
direnv: using flake
direnv: nix-direnv: using cached dev shell
/nix/store/4ia9i014ajl2l2cj75wzv5m463cisn4z-bash-5.2p26/bin/bash
/run/current-system/sw/bin/bash
/bin/bash Does this show that the nixpkgs-provided |
I thought we fixed homebrew to also build with its own version bash? Homebrew/homebrew-core@b800fa7#diff-fb911d9f81daeaf60cca24c468e574351ef2dabe8845478bfedf1ac931587cb4R24 |
Ah - I had forgotten that we'd done this. |
Possibly related to NixOS/nix#10263? |
@szlend indeed. We're working on a fix in nixpkgs and Nix to make the error message better.
The important part for users is to use bash with version 4.0.0 or higher. It can be installed from brew or nix, that doesn't matter, it just needs to be first in the path, so Another potential workaround is to not use nixpkgs unstable, but 23.11, as it does not include commit NixOS/nixpkgs@e07a2fa, which is the source of this error. EDIT: And the third option is to install direnv explicitly from Nix, and ensure only that version is hooked into the shell, because that version will only call the current version of bash from nixpkgs (currently 5.2+) |
@iFreilicht: Which check are you talking about above? I believe @Mic92 is referring to this check, which should be run unequivocally because it is checked before we execute (I will be very happy once |
Oh sorry, I was talking about this one. Disregard my comment about this, then. |
This depends on how direnv is set up. I actually opened this issue in the direnv github because I had the same problem: direnv/direnv#1256 direnv itself will use the exact bash path that was specified at compile time, or system bash if nothing was specified at compile time. So, when using direnv installed by Nix, you should be fine. But, if you have direnv installed from brew or some other source, then it will use system bash. |
Does this not satisfy the "specified at compile time"? This should say that the only bash to use is the one pointed at here, so we can be sure that the bash version we get is one we expect (and in fact - one from a known up-to-date source). and yet we've still got this bug report. So I'm not entirely sure that we've nailed down the entirety of the root cause here. |
Hmm, it definitely should, the relevant part of the makefile is pretty clear here. But how do you know that's how the affected users installed direnv? In my case, the offending version was installed through asdf-vm via the asdf-direnv plugin. |
A co-worker just pointed out to me that If you have:
You'll run into this exact problem. You're right to point out that we can't control how direnv gets installed - that's outside of our control (I just wish we could avoid triaging bugs that aren't our purview. Many - if not most - of our bugs these days seem to be improper setups or stuff like this that isn't really a thing we control...). The resolution here is - I think - to update direnv (if installed from nixpkgs or homebrew) OR to install a newer version of bash and avoid calling EDIT: It still isn't clear to me though why we're not failing earlier in the invocation by screaming about the bash version though... EDIT2:
|
I was facing this same problem, and the issue was, indeed the bash version. |
We check the version of the invoking shell. We document the version requirement. I am unsure why the invoking shell isn't triggering. Happy to accept PRs improving the situation. |
Ok, somehow I ended in this repo from devenv, but I think I didn't installed direnv from |
Devenv's got a version of nix-direnv built in. You'd need to speak with them about their "fork". Direnv also has a non-caching implementation of |
Given that there is nothing here for the nix-direnv developers to do, I am closing this issue. I think we ought to pin either this issue or a similar one so that users can find it quickly and without reopening a similar one (provided that they actually look). This is frustrating, but I do not know how we can check the versions of bash with which our dependencies are invoked :/ |
All good. @bbenne10 – sorry for my radio silence. We fixed the original issue in my org by 1) asking people to do a |
Multiple users in our organization have reported sudden issues with direnv. Seems to be resolved by clearing the direnv cache
rm -rf .direnv
and reloading the folder.User 1:
User 2:
All of these users are on macOS and have used the following instructions to install Nix, direnv, and nix-direnv:
It's never happened on my machines, but I have a different set up with a laptop running nix-darwin and a NixOS desktop.
The text was updated successfully, but these errors were encountered: