-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Bug] Registries with non-conventional tarball paths #238
Comments
I have been able to work around this issue by putting the two yarnrc files (one in the project directory, one in the user directory): ./.yarnrc
~/.yarnrc
So I'm guessing it's probably because yarnrc v1 doesn't support the nested objects that are used in v2? |
Next hurdle: The url to my custom registry is built on artifactory, and as such, looks something like this:
And yarn is returning a 404. On quick investigation, it seems like yarn is trying to fetch the package at I'll try to dig into yarn berry to see if i can tweak this myself but some direction could be very useful. |
Yes, the v1. To be honest I'm starting to wonder whether we shouldn't use a different name for the rc files, this whole thing is more confusing than I'd like 🙁
Interesting - you can look for the following string and add some debug before to figure out what's the actual URL and headers sent to the registry:
I'd suggest to use a condition like |
yep, just found it:
Which maps to this This line resolves the registry (https://my-host.com/artifactory/api/npm/npm-virtual/) with a path ( |
Now i just gotta figure out what our expected behavior is... should we just always join instead of resolve? Is there some weird support for always going to the host and then resolve from there? Does |
Oh 😮 No, this is definitely a bug I introduced in #233. Someone had reported a bug on Discord where Yarn was incorrectly joining paths (so it ended up as Ideally we should have:
|
Yeah that makes sense. I'll see if i can put a PR together with some tests... Though looking through the example PR, i don't know if i understand the test infrastructure. Looks entirely snapshot based. Might take me some time. |
New fun issue: Authorization. I'm now getting 401 errors once i'm hitting my url. Best guess right now is that the authorization header doesn't work with artifactory. This was working through these old settings in npmrc:
I've tried configuring the new v2 settings with what i figured were the analogues:
But it seems that is not sufficient. Whatever v1 was doing to authorize, v2 doesn't seem to following the same scheme. |
Alright, one more step up the ladder and one more blocker. I've fixed the login issue, had to use the artifactory provided Looking at verbose output from npm proper, i believe the path it needs to try is actually: Notice the extra @org in the npm version. Not sure where the resolution logic is for this one but npm install logic is still very much a black box to me. |
Re: the invalid path concatenation, I've submitted a fix via #240. Re: the invalid auth, I believe it's because you need to encode the string to base64 ( Re: the The v2 currently ignores this field and loads the package based on the convention that the tarball is located at The problem is that your Artifactory instance doesn't seem to follow this convention, and instead uses the |
@arcanis that's a bummer about artifactory going against convention. I suppose filing a bug there might be my only way to get around that... Is there anyway this can be done with a plugin/hook? I've seen code around allowing the plugin architecture but am not sure about if it's possible to intercept the resolution and make that change. If I was able to look, see the scope resolution and add in the additional logic specific to artifactory? |
I could see one way to make this work: when resolving the metadata, we could detect whether the You won't be able to change the registry url for such packages without manually editing the lockfile (just like it was in the v1), but at least it wouldn't affect most projects and wouldn't break compatibility. Would you like to give it a try? I think it should just be about adding a line here to check what's contained in |
Yeah i'll give it a shot. Just got pulled onto something else for today, so i'll take a look at this sometime tomorrow. Thanks for all your help! |
So i'm getting back to this sooner than i thought. Interesting behavior I just noticed: I configured a new project and installed yarn-berry there, and then i found that my ~/.yarnrc file (which had npmScopes configured) was wiped out at some point. Not sure exactly what happened but i had to reset the npmScopes in the config. Not sure what triggered this. Might file a separate issue to track that thing. |
@psachs21 If you get the chance, can you confirm that |
@arcanis I'll give it a shot. Sorry I wasn't able to make the modifications myself, i played around a little and then got pulled onto something entirely unrelated. I'll give it a shot. |
@arcanis hmm, still failing to resolve the packages on artifactory. It's just reporting 404s. I'll need to spend some more time digging into the details, see what url it's trying and why it's failing. |
So the new version is attempting to pull from |
ah... new version wiped out previous yarnrc options. Getting unauth now, but i think i'll need to wrangle some more with the config. Edit So the auth is not being sent, despite a proper registry in the config. Inspecting the response and associated request, i don't see anything auth being sent over the wire. .yarnrc.yml
The |
more digging, getting a little farther. Turns out, unlike current .npmrc,
|
@paul-sachs, I want to say thank you. Your comments were invaluable in figuring out how to authenticate with Artifactory using Yarn Berry 🙂 For anyone else who is trying to get Yarn Berry working with Artifactory, your .yarnrc.yml file should look like this (unless your using scopes): npmRegistryServer: "..."
npmAuthIdent: "your_artifactory_auth_token_not_your_username_and_password"
npmAlwaysAuth: true
|
Describe the bug
I am trying to setup yarn v2 but I have some custom registries. When i run
yarn config -c
, and error is output saying that the key is not correct. From what i've seen here, the config looks correct.I've tried using the yaml format for v2, but since my primary yarn command is v1, it seems necessary that the .yarnrc file is marked as v1.
To Reproduce
.yarnrc
Running
yarn config -v
outputs the following:Environment if relevant (please complete the following information):
The text was updated successfully, but these errors were encountered: