yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.35k stars 1.1k forks source link

[Bug?]: 405 (Method Not Allowed) on install of private registry dependencies #3721

Closed iDVB closed 2 years ago

iDVB commented 2 years ago

Self-service

Describe the bug

After migrating from Yarn v1 -> v3 and running yarn install I get...

The remote server failed to provide the requested resource
➤ YN0035: │   Response Code: 405 (Method Not Allowed)
➤ YN0035: │   Request Method: GET
➤ YN0035: │   Request URL: https://npm.pkg.github.com/@ourscope/eslint-config-react/-/eslint-config-react-2.1.0.tgz

this happens for both @ourscope/react-components and @ourscope/eslint-config-react

One thing that seems odd is the Request URL having a /-/ in it. and visiting that url in a browser nets with this...

{
"status": "error",
"message": "Method not allowed"
}

~/.yarnrc.yml (user home dir)

npmScopes:
  ourscope:
    npmAlwaysAuth: true
    npmAuthToken: "NOTTELLING"
    npmPublishRegistry: "https://npm.pkg.github.com"
    npmRegistryServer: "https://npm.pkg.github.com"

.yarnrc.yml (repo root)

yarnPath: .yarn/releases/yarn-3.1.0.cjs
nodeLinker: node_modules

Removing the npmAuthToken indeed errors with a not authorized error... so it seems the token is working properly.

package.json (workspace's package.json)

{
  "name": "frontend",
  "description": "Great stuff",
  "version": "1.0.0",
  "author": "Us",
  "bugs": {
    "url": "https://github.com/NOTTELLING"
  },
  "dependencies": {
    "@ourscope/react-components": "5.52.0",
    "@material-ui/core": "^4.12.3",
    "@material-ui/icons": "^4.11.2",
    "@material-ui/lab": "^4.0.0-alpha.58",
    "@material-ui/styles": "^4.11.3",
    "@material-ui/system": "^4.11.3",
    "@reach/router": "^1.3.4",
    "@react-three/drei": "^3.9.0",
    "autosuggest-highlight": "^3.1.1",
    "axios": "^0.21.1",
    "formik": "^2.2.0",
    "gatsby": "^3.6.2",
    "gatsby-cli": "^3.6.0",
    "gatsby-plugin-feed": "^3.1.0",
    "gatsby-plugin-google-gtag": "^3.1.0",
    "gatsby-plugin-hubspot": "^1.3.5",
    "gatsby-plugin-image": "^1.2.1",
    "gatsby-plugin-manifest": "^3.1.0",
    "gatsby-plugin-material-ui": "^3.0.1",
    "gatsby-plugin-react-helmet": "^4.1.0",
    "gatsby-plugin-sharp": "^3.2.1",
    "gatsby-plugin-styled-components": "^4.1.0",
    "gatsby-source-filesystem": "^3.1.0",
    "gatsby-transformer-sharp": "^3.1.0",
    "gsap": "3.6.0",
    "lodash": "^4.17.21",
    "prop-types": "^15.7.2",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-helmet": "^6.1.0",
    "react-intersection-observer": "^8.31.0",
    "react-is": "^17.0.1",
    "react-portal": "^4.2.1",
    "react-responsive": "^8.2.0",
    "react-slick": "^0.28.1",
    "react-three-fiber": "^5.3.19",
    "react-use": "^17.2.3",
    "styled-components": "5.2.0",
    "styled-icons": "^10.33.0",
    "three": "^0.127.0",
    "uuid": "^8.3.1",
    "yup": "^0.32.9"
  },
  "devDependencies": {
    "@babel/core": "^7.13.15",
    "@babel/preset-env": "^7.13.15",
    "@babel/preset-react": "^7.12.13",
    "@babel/register": "^7.13.8",
    "@ourscope/eslint-config-react": "^2.1.0",
    "@typescript-eslint/eslint-plugin": "^4.21.0",
    "@typescript-eslint/parser": "^4.21.0",
    "babel-eslint": "^10.1.0",
    "babel-loader": "^8.0.6",
    "babel-plugin-styled-components": "1.10.5",
    "babel-preset-gatsby": "^1.6.0",
    "dotenv": "^8.2.0",
    "eslint": "^7.22.0",
    "eslint-config-prettier": "^8.1.0",
    "eslint-config-react-app": "^6.0.0",
    "eslint-plugin-flowtype": "^5.6.0",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-mdx": "^1.13.0",
    "eslint-plugin-prettier": "^3.3.1",
    "eslint-plugin-react": "^7.22.0",
    "eslint-plugin-react-hooks": "^4.1.2",
    "eslint-plugin-simple-import-sort": "^7.0.0",
    "esm": "^3.2.25",
    "gatsby-plugin-no-javascript": "^2.0.5",
    "gatsby-plugin-remove-trailing-slashes": "^3.1.0",
    "gatsby-plugin-robots-txt": "^1.5.5",
    "gatsby-plugin-sitemap": "^4.1.0",
    "gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.22",
    "http-proxy-middleware": "^1.0.6",
    "lint-staged": "^10.5.4",
    "prettier": "^2.1.2",
    "typescript": "^4.2.4",
    "webpack-node-externals": "^3.0.0"
  },
  "resolutions": {
    "**/babel-plugin-styled-components": "1.10.5",
    "**/browserslist": "^4.16.6",
    "**/ws": "^7.4.6",
    "**/trim": "^0.0.3",
    "**/property-expr": "^2.0.3",
    "**/postcss": "^8.2.10",
    "**/lodash": "^4.17.21"
  },
  "homepage": "https://github.com/ourscope/nottelling#readme",
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/ourscope/nottelling.git"
  },
  "scripts": {
    "lint": "eslint --ext \".js,.ts,.tsx,.mdx\" .",
    "build": "gatsby build",
    "develop": "gatsby develop -H 0.0.0.0",
    "format": "eslint --fix --ignore-pattern public \"**/*.{js,jsx}\"",
    "start": "npm run develop",
    "serve": "gatsby serve -H 0.0.0.0",
    "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing \""
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "pre-push": "yarn lint",
      "post-rebase": "yarn install"
    }
  },
  "lint-staged": {
    "*.{js,ts,tsx}": [
      "eslint --fix"
    ]
  }
}

To reproduce

It's a private repo and token so not sure how to provide repro steps?

Environment

System:
    OS: macOS 11.6
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 14.15.1 - /private/var/folders/wg/0wjnjmw153n_smp01x_tp3zw0000gp/T/xfs-fdc5c3bc/node
    Yarn: 3.1.0 - /private/var/folders/wg/0wjnjmw153n_smp01x_tp3zw0000gp/T/xfs-fdc5c3bc/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v14.15.1/bin/npm

Additional context

The above was all done in a repo that already worked in v1 with workspaces. We just tried an empty folder... yarn init yarn set version berry yarn init (needed to run twice for some reason) yarn add @ourscope/react-components

and everything worked as expected... no issues and this would be with the same ~/.yarnrc.yml as above.

iDVB commented 2 years ago

Turns out our issue what that we we're not using the proper nodeLinker. We had it as node_modules and it was supposed to be node-modules.

Btw, who's decision was it to use a hyphen here?! 😅

merceyz commented 2 years ago

I'll reopen this as the error you included in the description is a real issue not related to the value in nodeLinker

ofagbemi commented 2 years ago

In case anyone's coming from search — I had a similar error and was able to fix it by just deleting my private package's entry in my yarn.lock file before running yarn install

merceyz commented 2 years ago

Fix has been released as 3.2.0-rc.9 (https://github.com/yarnpkg/berry/commit/16d65d77ad35dfbe184f305b9bbfaf70a61e0adb)

yarn set version berry && yarn set version canary
corytheboyd-cirrusmd commented 2 years ago

Turns out our issue what that we we're not using the proper nodeLinker. We had it as node_modules and it was supposed to be node-modules.

Btw, who's decision was it to use a hyphen here?! 😅

Just got bit by this as well. It should crash for unsupported values and tell you why IMO