-
Notifications
You must be signed in to change notification settings - Fork 154
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
fix: nodebuild call failure after initial install #409
Conversation
Signed-off-by: Marko Kungla <[email protected]>
I opened #407 yesterday. It looks like it's related. |
#414 would also be fixed by this I think. |
@augustobmoura can you take a look at this one? I think it's a good fix to accommodate asdf 0.16.0+. |
Signed-off-by: Marko Kungla <[email protected]>
Tested manually. Works (albeit with filename extension changes). Please fix and merge because |
@Stratus3D and @augustobmoura How is this repository maintained that such simple and obvious thing takes so long to merge? |
The maintainers have jobs and lives outside this project. And given the start of the year and the amount of international holidays, nobody is expected to work on a schedule. The bugs have workaround and you can always pin/downgrade asdf if that is bothering you. To be frank, I didn't even hit any of the problems because the plugin is pretty stable and I didn't upgrade asdf in the last months. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments, and BTW, I cannot hit the issue on asdf 0.16.3, are you sure this fix is even needed?
@@ -4,8 +4,28 @@ set -eu -o pipefail | |||
|
|||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../utils.sh" | |||
|
|||
: "${ASDF_NODEJS_NODEBUILD_HOME=$ASDF_NODEJS_PLUGIN_DIR/.node-build}" | |||
: "${ASDF_NODEJS_CONCURRENCY=$(((${ASDF_CONCURRENCY:-1} + 1) / 2))}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explanation of the problem:
ASDF_CONCURRENCY
was being defaulted here to 1
, so I don't think the problem was ASDF_CONCURRENCY
being unbound. But we always assumed it to be a number. Because it can now be defined to auto
, bash tries to interpolate it as $((auto + 1 / 2))
, which surprises me, I didn't know bash tries to interpolate variables in arithmetic expressions without the dollar sign.
if [[ "${local_concurrency:-auto}" == "auto" || -z "${local_concurrency}" ]]; then | ||
if command -v nproc >/dev/null 2>&1; then | ||
local_concurrency=$(nproc) | ||
elif [[ "$(uname)" == "Darwin" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double equals ==
and double brackets [[
are bashisms, please avoid them, we try to keep the project as compatible to POSIX shell as possible
local_concurrency
can not be empty since you are already setting it to something on line 8. We can simplify the first if condition further.
if [[ "${local_concurrency:-auto}" == "auto" || -z "${local_concurrency}" ]]; then | |
if command -v nproc >/dev/null 2>&1; then | |
local_concurrency=$(nproc) | |
elif [[ "$(uname)" == "Darwin" ]]; then | |
if [ "$local_concurrency" = auto ]; then | |
if command -v nproc >/dev/null 2>&1; then | |
local_concurrency=$(nproc) | |
elif [ "$(uname)" = Darwin ]; then |
fi | ||
|
||
# Ensure ASDF_NODEJS_PLUGIN_DIR is set | ||
ASDF_NODEJS_PLUGIN_DIR="${ASDF_NODEJS_PLUGIN_DIR:-$HOME/.asdf/plugins/nodejs}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NodeJS plugin home can change based on ASDF_DIR
and ASDF_DATA_DIR
, I prefer to just reference the local file, like in
Line 10 in 2bd35bc
export ASDF_NODEJS_PLUGIN_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) |
This variable should be defined anyway, since we are sourcing ASDF_CONCURRENCY
on line 5. We can remove this line here:
ASDF_NODEJS_PLUGIN_DIR="${ASDF_NODEJS_PLUGIN_DIR:-$HOME/.asdf/plugins/nodejs}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. If possible hardcoding paths should be avoided in plugins.
In my opinion this should be fixed by asdf-core, we shouldn't expect to resolve auto on every plugin |
Sorry all, been behind on PRs recently. @augustobmoura you are correct. This should not be the responsibility of this plugin. asdf core should handle this. In my opinion this |
Description:
From
asdf version v0.16.0
, this plugin breaks and fails when trying to install a Node version. This PR introduces a fix that addresses this issue forasdf >= v0.16.0
while ensuring backward compatibility with older versions ofasdf
.Changes Introduced:
asdf v0.16.0
and later versions.v0.16.0
.Testing:
asdf v0.16.0
and v0.15.0 to verify proper functionality.asdf
.Closes #407
Closes #412
Closes #414
Closes #415