jfrog / jfrog-cli-core

Apache License 2.0
32 stars 55 forks source link

jf yarn install - [🚨Error] invalid character 'u' looking for beginning of value #1166

Open chkp-roniz opened 3 months ago

chkp-roniz commented 3 months ago

I am not using scopes in my yarn project (just npmRegistryServer); hence, this line fails since yarn config get npmScopes is undefined https://github.com/jfrog/jfrog-cli-core/blob/a063de89c67c6bdcc5a7183eaee02dd375af5212/artifactory/commands/yarn/yarn.go#L323

Please skip if undefined and don't try to unmarshal it to JSON

chkp-roniz commented 3 months ago

Also, after setting an internal scope in npmScopes, jf yarn install freezes for a long time

# yarn config get npmScopes
{
  internal: {
    npmAlwaysAuth: false,
    npmAuthIdent: null,
    npmAuthToken: null,
    npmAuditRegistry: null,
    npmPublishRegistry: null,
    npmRegistryServer: 'https://artifactory.company.com/artifactory/api/npm/npm/'
  }
}

# jf yarn install
10:45:41 [Debug] JFrog CLI version: 2.52.9
10:45:41 [Debug] OS/Arch: linux/amd64
10:45:41 [🔵Info] Running Yarn...
10:45:41 [Debug] Preparing to read the config file /repo/.jfrog/projects/yarn.yaml
10:45:41 [Debug] Found resolver in the config file /repo/.jfrog/projects/yarn.yaml
10:45:41 [Debug] Preparing prerequisites.
10:45:41 [Debug] Found Yarn executable at: /usr/local/bin/yarn
10:45:41 [Debug] Working directory set to: /repo
10:45:41 [Debug] Found Yarn executable at: /usr/local/bin/yarn
10:45:42 [Debug] Sending HTTP GET request to: https://artifactory.company.com/artifactory/api/system/version
10:45:42 [Debug] Artifactory response: 200 OK
10:45:42 [Debug] JFrog Artifactory version is: 7.71.11
10:45:42 [Debug] Sending npm auth request
10:45:42 [Debug] Sending HTTP GET request to: https://artifactory.company.com/artifactory/api/npm/auth
10:45:42 [Debug] Sending HTTP GET request to: https://artifactory.company.com/artifactory/api/repositories/npm
10:45:42 [Debug] The file /repo/.yarnrc.yml was backed up successfully to jfrog.yarnrc.backup
EyalDelarea commented 2 months ago

Hey @chkp-roniz,

Could you please provide more details to assist us in resolving the issue?

Which version of Yarn are you using? Could you please provide detailed steps to reproduce the problem?

Your input will greatly aid us in addressing this matter effectively.

chkp-roniz commented 2 months ago
docker run -it artifactory.company.com/docker/node:latest /bin/bash

# node --version
v20.5.0

# yarn set version stable
➤ YN0000: You don't seem to have Corepack enabled; we'll have to rely on yarnPath instead
➤ YN0000: Downloading https://repo.yarnpkg.com/4.1.1/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-4.1.1.cjs
➤ YN0000: Done with warnings in 0s 288ms

# npm config set registry https://artifactory.company.com/artifactory/api/npm/npm/
# yarn config set npmRegistryServer https://artifactory.company.com/artifactory/api/npm/npm/

# <Install and config JF CLI>

# mkdir test && cd test && npm init...
/test# jf yarn install react
10:29:20 [🔵Info] Running Yarn...
10:29:21 [🚨Error] invalid character 'u' looking for beginning of value
EyalDelarea commented 2 months ago

Hey @chkp-roniz,

I noticed that you're currently using yarn v4.1.1, but it seems that the JFrog CLI doesn't support yarn version 4.x yet. While changing the specific line you mentioned might prevent the CLI from crashing, it's just one of many changes from the previous versions to v4 that needs to be done.

My suggestion would be to downgrade yarn to v3.8.1 if possible. I've tested it with this version of yarn, and it works well. Additionally, you could open a feature request for yarn v4 support, and we'll consider incorporating it into our roadmap.

Let me know if you have any more questions!