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

how can i use a module with setup-nu? #40

Open
amtoine opened this issue Apr 14, 2023 · 14 comments
Open

how can i use a module with setup-nu? #40

amtoine opened this issue Apr 14, 2023 · 14 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed

Comments

@amtoine
Copy link

amtoine commented Apr 14, 2023

hellord @hustcer 👋 😋

i have this CI where i try to use a module to update some data and push it automatically based on a schedule 😏
but it fails with that kind of error 🤔

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 👀

@amtoine
Copy link
Author

amtoine commented Apr 14, 2023

in the end i was able to work around the problem by

👍

@hustcer
Copy link
Owner

hustcer commented Apr 15, 2023

Thanks for the feed back, I will try to fix it, but I'm not sure is there a good way

@amtoine
Copy link
Author

amtoine commented Apr 15, 2023

Thanks for the feed back, I will try to fix it, but I'm not sure is there a good way

😊

not urgent at all 😌
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_DIRS variables in an env: block
  • and yeah, know about the current directory, especially with the checkout action, at parse-time

cheers 😋 👋

@hustcer
Copy link
Owner

hustcer commented Apr 19, 2023

I have tried many ways here: 24412a4, 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

@hustcer
Copy link
Owner

hustcer commented Apr 19, 2023

Maybe I can give it a try after nu v0.79 released due to nushell/nushell#8870

@hustcer
Copy link
Owner

hustcer commented Apr 19, 2023

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

@amtoine
Copy link
Author

amtoine commented Apr 19, 2023

@hustcer
wow thanks for all these tests, that's amazing 🤩

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 🤔

Maybe I can give it a try after nu v0.79 released due to nushell/nushell#8870

well if you find something and want someone to test 😏

@hustcer
Copy link
Owner

hustcer commented Sep 11, 2023

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

@amtoine
Copy link
Author

amtoine commented Sep 11, 2023

noice, will see if i encounter this again 😌

@hustcer hustcer added documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed labels Sep 21, 2023
@texastoland
Copy link

texastoland commented Mar 13, 2024

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)!

@hustcer
Copy link
Owner

hustcer commented Mar 14, 2024

@texastoland That's a good idea. PRs are welcomed.

@texastoland
Copy link

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?

@hustcer
Copy link
Owner

hustcer commented Mar 14, 2024

You can contact me by discord, username hustcer

@texastoland
Copy link

texastoland commented Mar 14, 2024

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 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants