setup-nu
setup-nu copied to clipboard
how can i `use` a module with `setup-nu`?
hellord @hustcer :wave: :yum:
i have this CI where i try to use a module to update some data and push it automatically based on a schedule :smirk: but it fails with that kind of error :thinking:
is it possible to use a module easily with setup-nu?
i tried changing NU_LIB_DIRS to contain pwd but that did not work :eyes:
in the end i was able to work around the problem by
- moving the module commands to standalone scripts in https://github.com/amtoine/nu-issue-tracker/commit/1503e4484c9f0a78183d79586402f097effae792
- call the executable scripts directly from the CI in https://github.com/amtoine/nu-issue-tracker/commit/e7a056f20c55cd94e5bda10c6dac2f854d5b61fd
:+1:
Thanks for the feed back, I will try to fix it, but I'm not sure is there a good way
Thanks for the feed back, I will try to fix it, but I'm not sure is there a good way
:blush:
not urgent at all :relieved:
the script fix does the job, it's just i love modules
ideas
- that could be nice to be able to set the
NU_LIB_DIRSvariables in anenv:block - and yeah, know about the current directory, especially with the
checkoutaction, at parse-time
cheers :yum: :wave:
I have tried many ways here: https://github.com/hustcer/setup-nu/commit/24412a454ca14e5b14b598f5bee67a06c6ab20c5, however, they all failed.
It seemed that I can change the NU_LIB_DIRS in setup-nu action, but it will be overrode thus not work
Maybe I can give it a try after nu v0.79 released due to https://github.com/nushell/nushell/issues/8870
The only way works I found is here: https://github.com/hustcer/setup-nu/blob/develop/.github/workflows/module-test.yaml You need to copy your modules to NU_LIB_DIRS and then use it in the following step:
- name: Cp Your Modules to NU_LIB_DIRS
run: |
let LIB_DIR = ($nu.config-path | path dirname | path join 'scripts')
mkdir $LIB_DIR
cp nu/common.nu $LIB_DIR
print 'Available Nu Modules:'
print (ls ($env.NU_LIB_DIRS | get 0))
- name: Use Your Nu Modules In the Following Steps
run: |
use common.nu [get-env]
print (get-env 'ABC-XYZ' 'DEFAULT-ABC-XYZ')
Running result: https://github.com/hustcer/setup-nu/actions/runs/4742880511/jobs/8421700478
@hustcer wow thanks for all these tests, that's amazing :star_struck:
You need to copy your modules to NU_LIB_DIRS and then use it in the following step:
oooh i see what you're doing here and that it works. i think i prefer the script alternative right now though :thinking:
Maybe I can give it a try after nu v0.79 released due to https://github.com/nushell/nushell/issues/8870
well if you find something and want someone to test :smirk:
Update: https://github.com/hustcer/setup-nu#use-modules It works for hustcer/[email protected], but not perfect, so I will leave this issue open
noice, will see if i encounter this again :relieved:
I came to request nupm default installation for nupm test but it would hypothetically make it easy to install modules from the registry too (recent addition)!
@texastoland That's a good idea. PRs are welcomed.
I looked at the code but it wasn't obvious where to start. I'm motivated to get it working for CI testing on nu_scripts though. Better in a channel or DM if I need help?
You can contact me by discord, username hustcer
Related to the original issue I tried all the following unsuccessfully:
shell: nu -I "$PWD" {0}shell: nu -I "$GITHUB_WORKSPACE" {0}shell: nu -I '${{ GITHUB_WORKSPACE }}' {0}shell: nu -I '${{ github.workspace }}' {0}
But use ${{ github.workspace }}/mod_name works great for now 👍🏼