-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Strange behaviour of source command in config.nu #4773
Comments
What you're trying to do may not be do-able in nushell. It's my understanding that writing a file happens at 'eval time' and sourcing a file happens at 'parse time' and I don't believe those two things ever mix. I'm hoping we can come up with some other solution that fits both nushell and zoxide. Nushell's architecture is just different and we don't try to be POSIX-like so |
The basic idea is that |
yup, understood. I still have this in my nushell v0.44 config.
|
@ajeetdsouza Would it be possible to add Unfortunately, as @fdncred said, it's a language design issue that's not easy to fix -- allowing it would have deep consequences and disallow many assumptions we currently rely on. |
@kubouch while that would work, it would break every time zoxide was upgraded. I don't want to rely on package managers to rewrite the script each time, moreso for a fast-changing shell like Nushell. |
@ajeetdsouza I see. The way you described (save and source file within the same script) is currently impossible. However, there might be a workaround: Within
Then, you could instruct users to put this to the
You would need to run |
@kubouch that's still a bit of a problem:
I suppose I could ask users to rerun this line every time they change settings or update Nushell, but I was trying for a method with less friction. Thanks for your help! It's unfortunate that the If this is impossible, let me know, so I can mark this issue as resolved. |
Ah, I see. I'm afraid regenerating the file after each change might be the best solution now. Currently, we don't have plans to change how |
I managed to fix this by adding CC @davidkna perhaps Starship can do something similar? |
@ajeetdsouza Since you have already found a workaround, and https://www.nushell.sh/book/thinking_in_nushell.html#think-of-nushell-as-a-compiled-language, can we close this issue? |
Absolutely, I think we can close this. |
Describe the bug
There are a couple of problems with the
source
command when I use it in myconfig.nu
.Suppose the file
~/foo
does not exist. Then the followingconfig.nu
file fails, saying that the file does not exist:However, the file should exist, because I just created it. However, when I go to check, I see that the file has not been created either.
Suppose the file
~/foo
had the contents"some code"
. Now, consider the followingconfig.nu
file:This should have sourced
other code
, because that's what I just wrote to the file. However, Nushell (incorrectly) ends up loadingsome code
. When I check, I see that~/foo
(correctly) containsother code
.Finally,
source
does not work with variables. This is strange behaviour, considering that everything else in Nushell does.How to reproduce
N/A
Expected behavior
N/A
Screenshots
No response
Configuration
Additional context
These issues are blockers for the implementation of the zoxide plugin on Nushell.
CC @fdncred
The text was updated successfully, but these errors were encountered: