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

Fish support script errors with 'return' outside of function definition #7152

Closed
isomorpheme opened this issue Oct 10, 2022 · 3 comments
Closed
Labels

Comments

@isomorpheme
Copy link

isomorpheme commented Oct 10, 2022

Describe the bug

I re-ran the latest install script to get the new scripts for Fish installed (#7014, #7040), but it looks like the script sourced by /etc/fish/conf.d/nix.fish crashes on my system's version of Fish.

Steps To Reproduce

  1. Install (multi-user) Nix 2.11.1 with the usual sh <(curl -L https://nixos.org/nix/install) --daemon (I did this from within Fish so I ran sh (curl -L https://nixos.org/nix/install | psub) --daemon instead.)
  2. Open a new terminal running Fish.
  3. Error:
    /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish (line 3): 'return' outside of function definition
      return
      ^
    from sourcing file /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish
        called on line 4 of file /etc/fish/conf.d/nix.fish
    from sourcing file /etc/fish/conf.d/nix.fish
        called on line 253 of file /usr/share/fish/config.fish
    from sourcing file /usr/share/fish/config.fish
        called during startup
    .: Error while reading file “/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish”
    
    (And nix-env etc. aren't available.)

Expected behavior

No error, and the right environment variables are loaded for Nix to work from Fish.

nix-env --version output

$ nix-env --version
nix-env (Nix) 2.11.1

(Ran from bash instead of fish.)

Additional context

$ fish --version
fish, version 3.3.1

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy
@isomorpheme
Copy link
Author

isomorpheme commented Oct 10, 2022

I'm guesing the problem is that older/newer versions of Fish than the one I'm using do allow return outside of functions, and that the fix is probably as simple as using exit instead.

Edit: yep, the option to use return outside of functions was added in 3.4: https://fishshell.com/docs/current/relnotes.html#id3

@isomorpheme isomorpheme changed the title Fish support script errors with "'return' outside of function definition' Fish support script errors with 'return' outside of function definition' Oct 10, 2022
@isomorpheme isomorpheme changed the title Fish support script errors with 'return' outside of function definition' Fish support script errors with 'return' outside of function definition Oct 10, 2022
@edolstra
Copy link
Member

I think this is fixed in #7105.

@isomorpheme
Copy link
Author

Oh, I should have thought to look through PRs as well. Thanks! I'll close this then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants