Closed micaherne closed 5 months ago
This also affects / is affected by #5 where we pass the initial node location to the PATH variable.
Actually grunt-cli is very simple and seems to be designed for running any version of grunt so there shouldn't be an issue with always installing the latest version.
I just did a quick test, it looks as though if you are in the Moodle root directory and run:
nvm install
nvm use
nvm will take the values from the .nvmrc file.
This might mean that a specific version does not need to be setup in the Docker file (as long as it still installs nvm)
I think that if you always use the latest version of node you might run into issues if you want to test against older versions of Moodle (that do need node 16 still)
That's useful, thanks for testing that Neill! We still need to install grunt-cli in the Dockerfile itself but I'm hoping it'll be enough just to let nvm install the latest version of that with the latest version of npm. As far as I can see, it should be ok once moodle-plugin-ci kicks in as it will use nvm to manage the correct version for the Moodle version you're running against. (At least if we don't have the NODE_VERSION environment variable confusing matters!)
I'm just trying to patch it just now :)
You would likely need to install grunt-cli at the same time you do the nvm install and use commands or you run the risk it will not be there for that version
Ah I hadn't thought of that! So if we do npm install -g grunt-cli
it'll install it globally but only for the version of npm that is running at the time? That could complicate things! I wonder if it might be safer to install grunt-cli inside the image (in the withMoodlePluginCiContainer step)
That sounds like the place to do it.
I did just poke in that file and noticed it was making assumptions about the node version as well though.
From what I recall about npm if you install something without the global keyword it is installed inside the project you are in, when global is used it is stored in an npm directory so that all projects can use it.
When you layer nvm on top the global place is specific to the node version. I remember having to run all the global commands again when I changed node version in the past with it.
I'm seeing this on running moodle-plugin-ci recently:
This appears (maybe) to be because the environment variable - NODE_VERSION - we're using to set the version of nodejs / npm to be installed initially, for installing grunt-cli, is overriding the moodle-plugin-ci handling of node versions for installing dependencies.
It looks as if moodle-plugin-ci has handled this itself since version 3: https://github.com/moodlehq/moodle-plugin-ci/blob/main/docs/UPGRADE-3.0.md?plain=1#L28 (presumably we've happened to have a compatible version until recently).
I can't remember if we used that name deliberately due to something to do with nvm, or if it's just a coincidence, but either way I suspect it's the issue and needs removed.
The question remains as to which version of npm to use for installing grunt-cli. I'd guess there could maybe be issues there if we were just to use the latest grunt-cli but having moodle-plugin-ci using an older version of grunt that's compatible with the .nvmrc node version.