-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Multiple Versions on a System #5214
Comments
not a maintainer, but i wouldn't bank on it :/. i'm needing nvm like functionality now too, but i am a big nvm fan :). looks like https://github.com/asdf-community/asdf-deno is goin |
the most built-in way is switching deno version with |
|
|
+1 for this. When i first saw deno, i search for this. Only solution for this now is asdf. It is good to have some kind of version management inbuilt with deno. I am a big fan of nvm. So we need something else for deno.if it is inbuilt. Much better 😍 |
@kitsonk I really think this problem has to be solved inside Deno itself. This is a much-needed feature and it's not that efficient to rely on external tools like |
It becomes an recursive type of problem, building into a binary the concept of multiple versions of a binary, and something that is potentially only applicable in certain use cases of which none of us have the experience of how important/meaningful it will be to have multiple runtime versions of Deno at the same time. Under the concept of "last responsible moment" to make a decision, it should at least wait until we have multiple stable releases. Even then, I would want/expect it to be a seperate tool on the CLI. |
I don't think that it's recursive. |
@MehrdadKhnzd, what other runtimes do this? what other programs do this? can you make a compelling, objective argument as to why this program should? |
The existing version managers are all platform-fragmented. While I don't agree that it's |
@cdaringe For example, we have .NET Core in which you can have multiple versions installed alongside each other, and you can specify which version to use with each project with a simple property in a config file in the project's folder. And this was always a problem for me in Node.js, even with good tools like |
@MehrdadKhnzd, respectfully, i'm not grokking what's a poor experience w/ nvm? |
.NET core is not a runtime binary. It is a set of library files. You still have the same version of a compiler. |
@cdaringe No, that's the problem. It's platform-specific. The Linux version has this support, but the Windows version hasn't. But now I don't request to support a file like |
@kitsonk I really can't see the difference, because as I know it's the only thing that matters. I can run dead-old projects alongside with new, fresh ones without a problem. |
@cdaringe I think everyone is hoping for a better story with
Part of the problem is awareness. I think a lot of people default to running programs by calling the associated binary ( If the solution is provided by the community, that's great! I just think Deno should help champion it. |
In addition, I generally don't know how we gonna specify a Deno runtime version for our Deno projects. As you've probably seen with Node.js, when you want to deploy your app into a platform like Heroku, you have to specify the version of Node.js so it can install the correct version of Node.js for your app and run it. But now that we don't have a |
In addition to asdf, there are other options. Similar to nvm https://github.com/axetroy/dvm |
@axetroy Thanks for your solution. The problem is that there are at least three versions of this |
An easy solution would be some kind of option to rename the That's the advantage that comes with a single executable, use it. |
I hope the ecosystem around |
I did a bit of research and according to me, axetroy/dvm seems to be the best. Why:
This can be ported over in rust (preferably a separate crate) and then integrated into deno itself. But here's the biggest issue: If a version manager gets integrated in deno now, you can switch the version to older deno version but cannot switch back because older versions don't have the integrated version manager. If it had to be done it should have been done in the beginning. Possible solution: port axetroy/dvm in rust and ship it as a separate optional executable officially. I'm just saying that an official dvm would be nice. Or at least select one of the dvm as the official one. |
I've been thinking about this and the ideal solution IMO is:
I don't think a deno-specific solution is the way to go as this is something that could benefit all binaries beyond Deno and it could be used for development on the deno repostory as well. As has been mentioned, asdf-vm is a good solution, but IMO its fatal flaw is that it's all shell scripts and so doesn't support Windows (WSL is not windows support). I think a rewrite of something with a design like asdf-vm, but with support for Windows is the best way to go here and then for Deno to promote that solution as the default way to install. Alternatively, perhaps there is already something similar that supports all three major operating systems? |
@maximousblk That's why @MehrdadKhnzd suggested this so early on. So it'd be possible to switch from Deno v10 to Deno v6 if your Project needs it. It's just to future proof the next versions of Deno. Though now I'm wondering how it'd work for imported modules. Since even something like |
@hokkqi The developers of libraries for Deno try to be as self conscious as possible, releasing versions for specific versions for Deno and indicating (in one way or another) which version can you use in what version of Deno |
@Soremwar You can write |
@hokkqi People like that usually don't stick around with Deno too long, mainly cause this ecosystem requires a lot more attention to details like that, reading documentation and such. I call it creating good devs by brute force :) However I think a library that could allow devs to throw an error in a Deno version lower than expected might be a good addition, since JavaScript doesn't provide a good solution to this issue, hence Deno as a standalone runtime can't do it either |
import {satisfies} from 'https://deno.land/x/semver@v1.0.0/mod.ts';
export class VersionError extends Error {
name = 'VersionError';
}
export function requireDenoVersion (semanticVersion: string): void {
const currentVersion = Deno.version.deno;
if (!satisfies(currentVersion, semanticVersion)) {
throw new VersionError(`Deno version ${currentVersion} does not satisfy ${semanticVersion}`);
}
}
export default requireDenoVersion;
import {requireDenoVersion} from './require-version.ts';
Deno.test('Deno is at least v1.2.1', () => {
requireDenoVersion('>=1.2.1');
});
Deno.test('Deno is less than v2', () => {
requireDenoVersion('<2');
});
Deno.test('Deno is at least v1.9', () => {
requireDenoVersion('>=1.9');
}); output:
|
I want to remind people here that |
What is the concrete proposal here? If there is no proposal this can be closed. You can already install multiple versions of Deno like this:
Or changing the default installation version: |
+1 on closing this then, since it's also already documented on deno.land/manual |
I don't think |
Suppose we could look in .deno before downloading |
I think the |
We should just extend Volta ( https://volta.sh/ ) to handle deno. The benefits:
See the page on Why Volta? |
Sounds like a generally good idea to me, though I'd pin it using a Or just generally lets people write software that lets you pin your code to a specific deno version |
Just as an FYI as to why the Volta folks might be against reusing existing keys like Although that referred to the format of Moreover, there already is some discussion going on around this topic in the Volta project: volta-cli/volta#731 |
@kdmadej Yeah, Deno doesn't have a concept of this yet (afaik), which is why I suggested introducing it as a "sensible default" for package/installation managers that might be written for Deno. It'd be especially helpful if a Project gets Archived/Abandoned and somebody else picks it up later with a new name. This way we'd only have a {
"engines": { "deno": ">=1.5" }
} instead of having multiple different versions of {
"softwareName": { "engines": { "deno": ">=1.5" } }
} for every single "Manager" that might get written |
I was about to open an issue for this, but thankfully I found this conversation. Deno has this perk of being a swiss army-like runtime for developers which Node never had, like linting, formatting, testing and even benchmarking. Not only that, but even bundling and compiling. In Node's world, we need to install and configure different tools for each of these purposes, like ESLint, Prettier, Jest, Webpack and so on. But there is another thing which most projects also uses: a Node version manager like NVM and Volta (U use Volta). It would be super great if something like this could just work: // deno.jsonc
{
"denoVersion": "1.32.1"
} And when running # No deno.jsonc in this folder
$ cd ~
$ deno --version
deno 1.33.4
# Now there is a deno.jsonc with the content as the example above
$ cd ~/repos/my-project
# Caches deno runtime in the first installation
$ deno --version
Downloading deno 1.32.1...
deno 1.32.1
# Reuses the cached runtime
$ deno --version
deno 1.32.1
$ cd ~
$ deno --version
deno 1.33.4 If some inspiration is needed, Volta is open source, written in Rust as well and is just as cross platform as Deno is (e.g. Windows, macOS, Linux). Someone may claim that checking the For example, FROM denoland/deno:1.32.1
ENV DENO_DISABLE_VERSION_MANAGER=1
WORKDIR /app
COPY mod.ts deno.jsonc ./
# Deno will never attempt to confirm its version in this container because of this environment variable
RUN deno cache
[...] That's to say that maybe this issue can be reopened? |
Hey there, and thanks for your great work!
I wonder if there's a built-in solution for having multiple versions of Deno on a single system. Honestly, I don't want to use stuff like
nvm
again. Is this feature currently available? Or will it be added to Deno?Thanks!
The text was updated successfully, but these errors were encountered: