Skip to content
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

@langchain/aws has broken dependency #6049

Open
5 tasks done
s-natsubori opened this issue Jul 12, 2024 · 9 comments
Open
5 tasks done

@langchain/aws has broken dependency #6049

s-natsubori opened this issue Jul 12, 2024 · 9 comments
Assignees
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@s-natsubori
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

import { ChatBedrockConverse } from "@langchain/aws";
const model = new ChatBedrockConverse({
      model: "anthropic.claude-3-5-sonnet-20240620-v1:0",
      region: "us-east-1",
      credentials: {
        secretAccessKey: "my-secret-key",
        accessKeyId: "my-access-key-id",
      },
    });

Error Message and Stack Trace (if applicable)

yarn install raise warning

warning "@langchain/aws > @aws-sdk/credential-provider-node > @aws-sdk/[email protected]" has unmet peer dependency "@aws-sdk/client-sts@^3.614.0".
warning "@langchain/aws > @aws-sdk/credential-provider-node > @aws-sdk/[email protected]" has unmet peer dependency "@aws-sdk/client-sts@^3.609.0".
warning "@langchain/aws > @aws-sdk/credential-provider-node > @aws-sdk/credential-provider-sso > @aws-sdk/[email protected]" has unmet peer dependency "@aws-sdk/client-sso-oidc@^3.614.0".

and build dead with error


 [ERROR] No matching export in "node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"

    node_modules/@aws-sdk/token-providers/dist-es/fromSso.js:2:25:
      2 │ import { getProfileName, getSSOTokenFromFile, loadSsoSessionData, parseKnownFiles, } from "@smithy/shared-ini-file-loader";
        ╵                          ~~~~~~~~~~~~~~~~~~~

X [ERROR] No matching export in "node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"

    node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js:3:9:
      3 │ import { getSSOTokenFromFile } from "@smithy/shared-ini-file-loader";
        ╵          ~~~~~~~~~~~~~~~~~~~

(MY_PRJ_PATH)\node_modules\esbuild\lib\main.js:1649
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 2 errors:
node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js:3:9: ERROR: No matching export in "node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"
node_modules/@aws-sdk/token-providers/dist-es/fromSso.js:2:25: ERROR: No matching export in "node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"
    at failureErrorWithLog ((MY_PRJ_PATH)p\node_modules\esbuild\lib\main.js:1649:15)
    at (MY_PRJ_PATH)\node_modules\esbuild\lib\main.js:1058:25
    at (MY_PRJ_PATH)\node_modules\esbuild\lib\main.js:1525:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: {
        column: 9,
        file: 'node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js',
        length: 19,
        line: 3,
        lineText: 'import { getSSOTokenFromFile } from "@smithy/shared-ini-file-loader";',
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'No matching export in "node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"'
    },
    {
      detail: undefined,
      id: '',
      location: {
        column: 25,
        file: 'node_modules/@aws-sdk/token-providers/dist-es/fromSso.js',
        length: 19,
        line: 2,
        lineText: 'import { getProfileName, getSSOTokenFromFile, loadSsoSessionData, parseKnownFiles, } from "@smithy/shared-ini-file-loader";',
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'No matching export in "node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"'
    }
  ],
  warnings: []
}

Description

Why @langchain/aws has unmet peer dependency?
Can I solve this fix some package version???

System Info

platform :windows
Node: v20.9.0
yarn: 1.22.19

"dependencies": {
    "@langchain/aws": "^0.0.1",
    "@langchain/core": "^0.2.9",
    "langchain": "^0.2.9",
}
@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Jul 12, 2024
Copy link

dosubot bot commented Jul 12, 2024

Hello, @s-natsubori! I'm here to help you with any questions or issues you may have. If you need assistance with bug fixes, code-related questions, or becoming a contributor, feel free to ask.

The unmet peer dependencies and build errors you're encountering with @langchain/aws are likely due to version mismatches between the @aws-sdk packages and the @smithy/shared-ini-file-loader package. To resolve these issues, you can align the versions of the @aws-sdk packages and ensure compatibility with the @smithy package.

Here are the steps to fix the package versions and resolve the unmet peer dependencies:

  1. Update @aws-sdk packages to compatible versions:
    Ensure that all @aws-sdk packages are using compatible versions. You can update the versions in your package.json to the latest compatible versions.

  2. Update @smithy/shared-ini-file-loader:
    Ensure that the @smithy/shared-ini-file-loader package is updated to a version that exports getSSOTokenFromFile.

Here is an example of how you can update your package.json:

{
  "dependencies": {
    "@langchain/aws": "^0.0.1",
    "@langchain/core": "^0.2.9",
    "langchain": "^0.2.9",
    "@aws-sdk/client-sts": "^3.614.0",
    "@aws-sdk/client-sso-oidc": "^3.614.0",
    "@smithy/shared-ini-file-loader": "^3.0.0"
  },
  "resolutions": {
    "@aws-sdk/client-sts": "^3.614.0",
    "@aws-sdk/client-sso-oidc": "^3.614.0",
    "@smithy/shared-ini-file-loader": "^3.0.0"
  }
}

Additionally, ensure that all LangChain packages depend on the same instance of @langchain/core by adding appropriate fields to your project's package.json:

{
  "name": "your-project",
  "version": "0.0.0",
  "dependencies": {
    "@langchain/aws": "^0.0.1",
    "langchain": "0.0.207"
  },
  "resolutions": {
    "@langchain/core": "0.1.5"
  },
  "overrides": {
    "@langchain/core": "0.1.5"
  },
  "pnpm": {
    "overrides": {
      "@langchain/core": "0.1.5"
    }
  }
}

This should resolve the unmet peer dependencies and the build errors by ensuring that all related packages are using compatible versions. If the issue persists, you may need to check for any additional updates or compatibility issues with the specific versions of the packages you are using.

To continue talking to Dosu, mention @dosu.

@s-natsubori
Copy link
Author

I try

{
  "dependencies": {
    "@langchain/aws": "^0.0.1",
    "@langchain/core": "^0.2.9",
    "langchain": "^0.2.9",
    "@aws-sdk/client-sts": "^3.614.0",
    "@aws-sdk/client-sso-oidc": "^3.614.0",
    "@smithy/shared-ini-file-loader": "^3.0.0"
  },
  "resolutions": {
    "@aws-sdk/client-sts": "^3.614.0",
    "@aws-sdk/client-sso-oidc": "^3.614.0",
    "@smithy/shared-ini-file-loader": "^3.0.0"
  }
}

install warning is resolved.
but still build is dead.

I did not try @langchain/core=="0.1.5"
Error raise from aws-sdk, so langchain version is not problem. may be.

@jacoblee93
Copy link
Collaborator

CC @bracesproul

@bracesproul bracesproul self-assigned this Jul 13, 2024
@bracesproul
Copy link
Member

Hey @s-natsubori I'm unable to reproduce the build error with the code sample you provided:

import { ChatBedrockConverse } from "@langchain/aws";
const model = new ChatBedrockConverse({
  model: "anthropic.claude-3-5-sonnet-20240620-v1:0",
  region: "us-east-1",
  credentials: {
    secretAccessKey: "my-secret-key",
    accessKeyId: "my-access-key-id",
  },
});

Could you provide a public github repo which will allow be to reproduce the issue?

@massi-ang
Copy link

massi-ang commented Aug 23, 2024

@bracesproul Hi Brace, I am facing the same issue when adding @langchain/aws to a project that uses esbuild. To reproduce you can clone and build this project: https://github.com/massi-ang/obsidian-textgenerator-plugin/tree/feat_bedrock. Note the branch in not master but feat_bedrock

@DanielOrtel
Copy link

DanielOrtel commented Oct 22, 2024

Edit: confirmed that the issue was with file extensions being omitted from the es build of shared-ini-file-loader, raised an issue with them: smithy-lang/smithy-typescript#1425

@bracesproul Similar error when importing from in a vite-based build:

✘ [ERROR] No matching export in "../../node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"

    ../../node_modules/@aws-sdk/token-providers/dist-es/fromSso.js:2:25:
      2 │ import { getProfileName, getSSOTokenFromFile, loadSsoSessionData, parseKnownFiles, } from "@smithy/shared-ini-file-loader";
        ╵                          ~~~~~~~~~~~~~~~~~~~

✘ [ERROR] No matching export in "../../node_modules/@smithy/shared-ini-file-loader/dist-es/index.js" for import "getSSOTokenFromFile"

    ../../node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js:4:9:
      4 │ import { getSSOTokenFromFile } from "@smithy/shared-ini-file-loader";
        ╵          ~~~~~~~~~~~~~~~~~~~

✘ [ERROR] No matching export in "../../node_modules/@aws-sdk/credential-provider-web-identity/dist-es/index.js" for import "fromTokenFile"

    ../../node_modules/@aws-sdk/credential-providers/dist-es/fromTokenFile.js:1:9:
      1 │ import { fromTokenFile as _fromTokenFile } from "@aws-sdk/credential-provider-web-identity";
        ╵          ~~~~~~~~~~~~~

Problem appears in an ESM environment. I'm not 100%, but I think that the culprit is the fact that there are no extensions for the files imported in @smithy/shared-ini-file-loader/dist-es/index.js:

export * from "./getHomeDir";
export * from "./getProfileName";
export * from "./getSSOTokenFilepath";
export * from "./getSSOTokenFromFile";
export * from "./loadSharedConfigFiles";
export * from "./loadSsoSessionData";
export * from "./parseKnownFiles";
export * from "./types";

In ESM, file extensions are mandatory, so this should be:

export * from "./getHomeDir.js";
export * from "./getProfileName.js";
export * from "./getSSOTokenFilepath.js";
export * from "./getSSOTokenFromFile.js";
export * from "./loadSharedConfigFiles.js";
export * from "./loadSsoSessionData.js";
export * from "./parseKnownFiles.js";
export * from "./types.js";

Copy link

dosubot bot commented Jan 22, 2025

Hi, @s-natsubori. I'm Dosu, and I'm helping the LangChain JS team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • The issue involves a broken dependency in the @langchain/aws package due to unmet peer dependencies.
  • A build error with the @smithy/shared-ini-file-loader module was reported.
  • Despite updating package versions, the build error persisted.
  • @DanielOrtel identified missing file extensions in the ESM build as the root cause and raised an issue with the smithy-typescript maintainers.

Next Steps:

  • Please confirm if this issue is still relevant with the latest version of the LangChain JS repository. If so, you can keep the discussion open by commenting here.
  • If there is no further activity, this issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Jan 22, 2025
@jacoblee93
Copy link
Collaborator

Commenting to keep this open, @DanielOrtel any updates? I think you linked the wrong issue on AWS.

@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Jan 22, 2025
@DanielOrtel
Copy link

Yeah, I linked the wrong one appearantly: smithy-lang/smithy-typescript#1437, same issue with AWS sdk: aws/aws-sdk-js-v3#3622.

The update so far is that they're not willing to fix it, due to it requiring a larger rewrite of their build process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

5 participants