Skip to content

jooby-frontend Yarn implementation fails to download Yarn #1037

@auxiliaire

Description

@auxiliaire

org.jooby.frontend.Yarn cannot download yarn because it tries to download npm instead:

INFO  [2018-02-23 00:32:00,439] [Hotswap] Installing npm version v1.3.2
INFO  [2018-02-23 00:32:00,439] [Hotswap] Downloading https://github.com/yarnpkg/yarn/releases/download/npm-v1.3.2.tgz to C:\Users\vikto\.m2\repository\com\github\eirslett\npm\1.3.2\npm-1.3.2.tar.gz
INFO  [2018-02-23 00:32:00,440] [Hotswap] No proxies configured
INFO  [2018-02-23 00:32:00,440] [Hotswap] No proxy was configured, downloading directly
INFO  [2018-02-23 00:32:01,637] [Hotswap] Stopped
febr. 23, 2018 12:32:01 DE org.apache.http.client.protocol.ResponseProcessCookies processCookies
ERROR [2018-02-23 00:32:01,639] [Hotswap] An error occurred while starting the application:
WARNING: Invalid cookie header: "Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Mon, 22 Feb 2038 23:32:01 -0000; secure; HttpOnly". Invalid 'expires' attribute: Mon, 22 Feb 2038 23:32:01 -0000
com.github.eirslett.maven.plugins.frontend.lib.InstallationException: Could not download npm
	at com.github.eirslett.maven.plugins.frontend.lib.NPMInstaller.installNpm(NPMInstaller.java:167)
	at com.github.eirslett.maven.plugins.frontend.lib.NPMInstaller.install(NPMInstaller.java:82)
	at org.jooby.frontend.Yarn.newTask(Yarn.java:357)

Clearly tries to download a wrong filename: https://github.com/yarnpkg/yarn/releases/download/npm-v1.3.2.tgz
When we check Yarn.java:357 we see the following:

    factory.getNPMInstaller(proxy)
        .setNpmVersion(yarnVersion)
        .setNodeVersion(nodeVersion)
        .setNpmDownloadRoot(conf.getString("yarn.downloadRoot"))
        .setUserName(property.apply("yarn.username"))
        .setPassword(property.apply("yarn.password"))
        .install();

But eirslett/frontend-maven-plugin provides proper Yarn installer as well.

Changing the lines to the following will result a proper download:

    factory.getYarnInstaller(proxy)
            .setYarnVersion(yarnVersion)
            .setYarnDownloadRoot(conf.getString("yarn.downloadRoot"))
            .setUserName(property.apply("yarn.username"))
            .setPassword(property.apply("yarn.password"))
            .install();

The next line is similarly wrong, as it uses the NpmRunner instead of YarnRunner.
Original:

    NpmRunner npm = factory.getNpmRunner(proxy, conf.getString("yarn.registryURL"));

Required:

    YarnRunner yarn = factory.getYarnRunner(proxy, conf.getString("npm.registryURL"));

Should I create a pull request for that?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions