nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

Can't set an environment variable in a task #10851

Closed deech closed 4 years ago

deech commented 5 years ago

I don't seem to be able to set an environment variable in a nimble task, am I missing something?

task t, "t":
   echo existsEnv("FOO")
   putEnv("FOO", "foo")
   echo getEnv("FOO")

Doing nimble t outputs:

false
          <-- note empty line
genotrance commented 5 years ago

putEnv isn't implemented in nimble's VM.

https://github.com/nim-lang/nimble/blob/master/src/nimblepkg/nimscriptsupport.nim

I had originally authored a PR for this.

https://github.com/nim-lang/nimble/pull/541

My current idea is to remove the VM altogether and run nimble scripts through Nim. It is still TBD.

Araq commented 5 years ago

My current idea is to remove the VM altogether and run nimble scripts through Nim. It is still TBD.

If it helps to motivate you, I'm really looking forward to this! :-)

dom96 commented 5 years ago

@genotrance I'm still skeptical about the performance of this. Sure, you can cache it but the performance will still be horrible when installing packages as most of them are going to be new. This won't be a problem for now when we don't have a lot of packages but in the future it'll become a massive scalability problem.

I would personally much rather push the nimscript evaluation to the Nim binary, this would free Nimble of this horrible dependency, which would have a number of advantages:

genotrance commented 4 years ago

This has been fixed in Nimble and works as expected now.