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
Allow DDEV nodejs_version
to use external file as reference for node version
#6071
Comments
Hi @n8-dev, In fact, we recommend using # use the latest 20 version
nodejs_version: v20
# use the exact version
nodejs_version: 20.1.0
# use the latest whatever it is
nodejs_version: latest
If I understand it correctly, you need to make adjustments to your .bashrc to use This can be done by adding a global |
If you remove But using the version you want there is so much easier than nvm. nvm is a shell-based utility which is never very predictable. |
I think the point is not about What Nate is suggesting is that if |
Thanks @GuySartorelli, I get the idea. There is Unfortunately we cannot use We could add our own logic to read the |
Although this is a great path for folks that use nvm, nvm is just a really poor cousin to other node version managers. It's bash based, and requires loading a bash recipe into every bash shell. It's just not a great thing, and we have a nice setup as it is, with nodejs_version. I'm going to close this for now, but happy to continue the conversation. |
I can kinda get where stasadev is coming from - adding this functionality would be more code to support in order to remove a small amount of complexity for users. So there's a tradeoff there and if y'all don't want to make that tradeoff, that's your call. Randy I don't get where you're coming from at all. Nvm is very popular and very common. I can understand recommending against it's use for people who are using DDEV - but the scenarios here are a) collaborating on a project with people who do not use DDEV, and b) using |
Good thoughts, reopening. |
Since there have been no further objections or concerns about this, I've gone ahead and created #6108 to address it. |
I apologize, but I will have objections. This would be a massive and incompatible change. The current status of leaving out nodejs_version is to get the default. And the majority of people do not use nvm. |
That's fair and is your prerogative as maintainer - though I wish you'd said that sooner 😅
The proposal is not to change this behaviour - it's just a shift in what "the default" refers to. But there are other ways to go about this if you want "the default" to always mean the hardcoded default version DDEV has defined in If you want that default value to always be hardcoded, other options include:
I'm open to other options as well which would help achieve this goal while not introducing changes you see as being massive. |
Just out of curiousity, and it needn't affect anything about the outcome here, but I'm curious if that's something that's being tracked in the stats DDEV gets about projects, and if so, how that is being determined? Also, if that assertion is true... this change wouldn't affect the majority of people, which should hopefully mitigate your concern of the level of impact this would have. |
First, I sure do appreciate your initiative, and your skill! I'm sorry the conversation didn't get finished before you invested the work.
Well, I did in fact close the issue, but reopened it based on your objection, but yours was the only one.
That's a big shift :) And more so for people who aren't using nvm in their normal workflow. I think it might not be received well. I understand the advantage for people who do use nvm.
DDEV tracks commands, so tracks |
I think the number of people using Regardless, let's take as a given that the number of people with a Are any of the suggested alternative ways to achieve this goal outlined in my comment above suitable? Note that none of my suggested alternatives will have any impact on the default versions or on existing DDEV config - they're all explicitly opt-in. |
(On vacation the next few days, I'm sure we'll take this up some more. Thanks for advocating.) |
I would hazard that It is used in a set up a "project vibe" right? and ultimately in the scope of DDEV isn't needed as a command at all... if you run your front end things in the container... Also, the whole situation would be
And therefore be surprised by that change to pick up the file would be quite small surely... that's a lot of conditions to be met with that problem.
I guess this begs the question. when DDEV updates the default And unless I'm upgrading my project at the exact same time I update DDEV its a breaking change now. |
I think the best solution would be the following. Allowing Arguably then this is agnostic.
I will edit the initial issue to have this as preference. As the more I think about it DDEV shouldn't have an opinion on what other tools I may use, its focus is on building containers for me. If I have a config in a file, cool, it shouldn't matter further than that. |
nodejs_version
to use external file as reference for node version
Over the years, our team has found itself with mismatched Node.js versions declared across multiple config files for different environments, e.g. production on 14, Tugboat/staging environments on 18, GitHub Actions (for CI, tests, sometimes building deployment artifacts) using 16 and local environments (via Lando at the time) gods-know-what. This has happened time and time again across various client projects because it is an easy thing to miss. I have been on a crusade to eradicate this problem by declaring the Node.js version to be used in any given project in a That is why I support adding the ability to point DDEV to a file where the version to be used can be declared. This can take the shape of a relative path passed to the existing In case anyone is wanting to solve this problem without using # .ddev/config.yaml
hooks:
post-start:
- exec: export N_PREFIX=$HOME && npm install --global n && n auto && hash -r
service: web After a
Ideally, however, no |
The fundamental problem with .nvmrc is that it pushes nvm onto people, and that certainly is not a majority workflow. We don't need to integrate one population's workflow onto another population. I'm open to generalized solutions that do not push particular workflows. |
Having a Regardless, the current proposal isn't to hardcode anything for What's more it's proposed that this be opt-in. Nobody has to use it, but people can use it if it'll be useful for them. |
That's what is being proposed. Allow The file does not matter (as it which workflow it belongs to) No workflow is being forced on anyone. DDEV maintains no opinion on a particular workflow. |
Is there an existing issue for this?
Is your feature request related to a problem?
Currently I have a
.nvmrc
file, other tools in the pipeline runs the following in it's set upI came across this as I noticed that the
nodejs_version
default, did not match my package.jsonengine
definition.That is already managed for other people not on DDEV and CI tooling via .nvmrc
Ultimately I'd like to not have to manage multiple places...
Describe your solution
It would be nice if I could remove thenodejs_version
and DDEV would check for a.nvmrc
file and take the number from there.Allowing
nodejs_version: path/to/file OR version
It could to take the version number from a defined file
It can break if you pass something wrong, that's on you.
Arguably then this is agnostic.
eg
.n-node-version
n's file.node-version
many many many more version managers.nvmrc
nvmDescribe alternatives
(was initially main solution)
It would be nice if I could remove the
nodejs_version
and DDEV would check for a.nvmrc
file and take the number from there.additional config for
nvmrc_path
or something perhaps to use instead or something...Though usually that is only in root.
Additional context
No response
The text was updated successfully, but these errors were encountered: