-
Notifications
You must be signed in to change notification settings - Fork 222
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 to change the version of a package dependency? #2460
Comments
Devbox Version 0.13.7Reason For IssueHi. I've looked into this, and I think its more of a I've noticed the config file at $ tail -n 1 .devbox/nix/profile/default/share/sbt/conf/sbtopts
-java-home /nix/store/f042x32jfm94d3cgaga8d6xl8vy6sg46-openjdk-21.0.5+11/lib/openjdk If you delete this file, sbt will correctly use java23, however that's a rough workaround. A better option is to override that config value with one of sbt's comand line options. $ sbt --help | grep java-home
--java-home <path> alternate JAVA_HOME
$ echo $JAVA_HOME
/nix/store/16ygp40ximgpl6iwg0vjral2kp1bqn52-temurin-bin-23.0.0
$ sbt --java-home $JAVA_HOME -v
[sbt_options] declare -a sbt_options=()
[process_args] java_version = '23'
[copyRt] java9_rt = '/home/ubuntu/.sbt/1.0/java9-rt-ext-eclipse_adoptium_23/rt.jar'
# Executing command line:
/nix/store/16ygp40ximgpl6iwg0vjral2kp1bqn52-temurin-bin-23.0.0/bin/java
-Dfile.encoding=UTF-8
-Xms1024m
-Xmx1024m
-Xss4M
-XX:ReservedCodeCacheSize=128m
-Dsbt.script=/home/ubuntu/sbtj/.devbox/nix/profile/default/bin/sbt
-Dscala.ext.dirs=/home/ubuntu/.sbt/1.0/java9-rt-ext-eclipse_adoptium_23
-jar
/nix/store/y05q6q62na3153cvwjsywxakkzwzzsdp-sbt-1.10.6/share/sbt/bin/sbt-launch.jar
[info] welcome to sbt 1.10.6 (Eclipse Adoptium Java 23) devbox.json fileBetter yet, you can update the devbox.json init hook to set up an alias for sbt so that you don't have to pass the option everytime. {
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.13.7/.schema/devbox.schema.json",
"packages": [
"[email protected]",
"temurin-bin-23@latest"
],
"shell": {
"init_hook": [
"alias sbt='sbt --java-home $JAVA_HOME'"
],
"scripts": {
"test": [
"echo \"Error: no test specified\" && exit 1"
]
}
}
} |
Thank you very much, your way around the problem works. But I think it’s not just about SBT. I found in the nixpkgs repository a discussion of exactly the same problem. And here is what the author of sbt package says:
As far as I understand the ideology of Nix, I think he is right. One of the key features of Nix is to combine different packages with each other to get exactly what you need at the output. Therefore, almost all packages are parameterized and accept at the input the definition of other packages on which they depend. And then they tie themselves to these dependencies in different ways. For example, I looked at the definitions of other popular packages that depend on the JDK:
I'm sure, the packages dependent on NodeJS and other SDKs are designed in much the same way. This is contrary to the current approach of devbox, which tries to work in the same way as traditional package managers that give you a set of packages with fixed dependency versions. Use or not, other options are not usually provided. That’s why developers usually don’t use This is missing from the devbox project. If it wants to become a viable alternative to the above managers, it should come up with a way of composing different versions of packages with each other, but not forcing the user to learn the Nix language. It would be killer feature! Now, it turns out that the end user, having installed a package dependent on some SDK, should study the definition of this package on Nix and find a way to bypass its binding to the specific version of the SDK. Then what is the point of using devbox if you still have to learn Nix. |
I stand corrected. You make a very good point. Wasn't aware of Nix defining dependencies for each package, but it makes sense in retrospect. It would make sense if devbox supported this as well. |
imho it is probably not the goal of the project. |
+1 on being able to force some type of overrides on transient dependencies, or for the defined environment to take precedents over the upstream. Ran into this issue as well, which is not really the expected functionality when I'm also defining the required JDK in the Devbox config. I think this should, at the very least, be called out in the Java env example in the documentation. It'll save some debugging time for the Java crowd hopefully. If you ask me, this kinda defeats the purpose of Devbox (albeit very easy workaround here for SBT). The point of it being abstracted is for it to be user-friendly with easily defined and reproducible environments, as well as altering the underlying functionality to make it more usable than Nix. Just because "thats how nix works", doesn't mean that's how it should work on Devbox, else what's the point in the abstraction? Would love to see this be taken up as a feature request, something similar to npm overrides in the json config would help bring Devbox to another level: https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides . |
I don't disagree that it would be nice.
|
I just started using
devbox
and encountered the following problem. Some packages depend on other packages with specific versions. Sometimes you need to change the version of a dependency to another one. But I haven’t found in the documentation how to do that.For example, my project is developed in the Scala language, so I have installed the SBT build system. The SBT package is tied to JDK 21, but I want to use JDK 23 because SBT knows how to work with it. My project also relies on the capabilities of JDK 23. So I have the following configuration:
If you run the
devbox shell
and look at thejava --version
andJAVA_HOME
, it matches what you expect:However, SBT still runs through JDK 21:
Is there a way to solve this problem, or do I need to learn
nix
and build my own SBT package with the dependencies I want? In this case thedevbox
idea is significantly devalued.The text was updated successfully, but these errors were encountered: