nvm icon indicating copy to clipboard operation
nvm copied to clipboard

bypass aliased curl

Open ryenus opened this issue 3 years ago • 12 comments

Use command curl ~add nvm_curl~ so that we can bypass aliased curl.

Context: https://github.com/nvm-sh/nvm/issues/2923#issuecomment-1299535388

ryenus avatar Nov 02 '22 04:11 ryenus

With these changes, there's only two places nvm_curl is needed, which suggests that inlining command may be a better choice?

if we keep nvm_curl, we need to remember to unset it in deactivate. also, there may be tests mocking curl that need to now mock nvm_curl.

Indeed, with only 2 places need the -q option I agree it's simpler to avoid the nvm_curl function, which also make testing less complicated. I've updated the PR accordingly.

ryenus avatar Nov 02 '22 06:11 ryenus

Testa are failing on master

Looking at the failed test here: https://app.travis-ci.com/github/nvm-sh/nvm/jobs/586754000

✗ nvm_list_aliases works with LTS aliases expected lts/gallium, got >lts/hydrogen<

I believe it's because of outdated test data. hopefully it can be fixed by https://github.com/nvm-sh/nvm/pull/2933

ryenus avatar Nov 02 '22 15:11 ryenus

Unfortunately it’s much more difficult than that; xenial can’t build node 18 and newer Ubuntus can’t build node 0.6.

ljharb avatar Nov 02 '22 15:11 ljharb

Checked, all looks as if will work as expected and resolves #2923

jordyjwilliams avatar Nov 03 '22 01:11 jordyjwilliams

Running the edited command curl for me does not log the edited one.

jordyjwilliams avatar Nov 03 '22 01:11 jordyjwilliams

Got tests passing on master and rebased this.

ljharb avatar Dec 23 '22 19:12 ljharb

Automatic Rebase

ZackaryJacobthereal avatar Jan 09 '23 14:01 ZackaryJacobthereal

@ryenus tests are still failing - specifically the ones that mock curl. are you interested in completing this PR? if not, please leave it open so I (or another contributor) can give it a shot :-)

ljharb avatar Jan 09 '23 21:01 ljharb

@ljharb I just realized that the test for nvm_curl_libz_support assumes that curl can be redefined as a shell function, therefore I'm keeping it as-is.

ryenus avatar Jan 10 '23 07:01 ryenus

@ryenus indeed - so i think that with this PR's change, to keep that test passing, we'd have to make the test instead mock out the PATH and provide an actual fake curl binary.

ljharb avatar Jan 10 '23 07:01 ljharb

so i think that with this PR's change, to keep that test passing, we'd have to make the test instead mock out the PATH and provide an actual fake curl binary.

@ljharb you're right, though IMHO it's a bit too much, as I think in the original issue it's likely a problem with the specific alias definition, not that the curl command cannot be aliased. If that's fine I'd like to close the pr instead.

ryenus avatar Jan 10 '23 10:01 ryenus

Let's keep it open; I'll try to get back to it and finish it.

ljharb avatar Jan 10 '23 22:01 ljharb