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

Cannot run python code (or anything non-shell?) in a task #1640

Open
flaw opened this issue Dec 12, 2024 · 0 comments
Open

Cannot run python code (or anything non-shell?) in a task #1640

flaw opened this issue Dec 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@flaw
Copy link

flaw commented Dec 12, 2024

It seems it's not possible to run non-shell scripts in a tasks: entry.

Given a config like

  tasks."python:hello" = {
    exec = ''print("Hello, world!")'';
    binary = "python3";
    package = config.languages.python.package;
  };

when I try to run it, I see:

--- python:hello failed with error: Task exited with status: exit status: 1
--- python:hello stdout:
--- python:hello stderr:
0000.00: Traceback (most recent call last):
0000.00:   File "/nix/store/54s3d671wvdnih712v7qszixim53n568-python-hello", line 2, in <module>
0000.00:     set -e
0000.00: NameError: name 'e' is not defined

Problem seems to be that the generated script contains a rogue set -e:

❯ cat /nix/store/54s3d671wvdnih712v7qszixim53n568-python-hello
#!/nix/store/ibjjy3ab86hiib290mcrmmzghqqr4hg2-python3-3.8.13/bin/python3
set -e
print("Hello, world!")
@flaw flaw added the bug Something isn't working label Dec 12, 2024
@flaw flaw changed the title Cannot run python code (or anything non-shell?) in a task or script Cannot run python code (or anything non-shell?) in a task Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant