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

[BUG] Issue with CloudscapeReactTsWebsiteProject package name with InfrastructureTsProject #659

Closed
JoshuaToth opened this issue Nov 22, 2023 · 2 comments
Labels
bug Something isn't working needs-triage

Comments

@JoshuaToth
Copy link
Contributor

JoshuaToth commented Nov 22, 2023

Describe the bug

If the package name property of a CloudscapeReactTsWebsiteProject construct is 'frontend' and the project is then included on the InfrastructureTsProject as the cloudscapeReactTsWebsite the pdk command will fail with a build error around node-gyp, with its libraries not being properly generated (or truncated?).

const anything = new CloudscapeReactTsWebsiteProject({
  parent: project,
  outdir: "packages/frontend",
  name: "frontend"
});

new InfrastructureTsProject({
  parent: project,
  outdir: "packages/infra",
  name: "infra",
  cloudscapeReactTsWebsite: anything,
});

The package name seems to be fine for anything else I've tried. 'website' (default), 'bar', 'pdkisawesome' etc.

The outdir doesn't seem to have anything to do with it, and can be 'frontend' or whatever with no issue.

Initially you get an error about python2 not being available in the shell as a command.
Adding in python2 as a command through pyenv results in the truncated node-gyp library (tested in node 18 and 20).

These issues don't occur with any other package name.

Expected Behavior

That package name doesn't cause an error with the pdk command.

Current Behavior

Error without python2
.../node_modules/node-sass postinstall$ node scripts/build.js
│ Building: /Users/joshtoth/.nvm/versions/node/v20.5.0/bin/node /Users/joshtoth/dev/project_dir/node_modules/.…
│ gyp info it worked if it ends with ok
│ gyp verb cli [
│ gyp verb cli   '/Users/joshtoth/.nvm/versions/node/v20.5.0/bin/node',
│ gyp verb cli   '/Users/joshtoth/dev/project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/bin/…
│ gyp verb cli   'rebuild',
│ gyp verb cli   '--verbose',
│ gyp verb cli   '--libsass_ext=',
│ gyp verb cli   '--libsass_cflags=',
│ gyp verb cli   '--libsass_ldflags=',
│ gyp verb cli   '--libsass_library='
│ gyp verb cli ]
│ gyp info using node-gyp@3.8.0
│ gyp info using node@20.5.0 | darwin | arm64
│ gyp verb command rebuild []
│ gyp verb command clean []
│ gyp verb clean removing "build" directory
│ gyp verb command configure []
│ gyp verb check python checking for Python executable "python2" in the PATH
│ gyp verb `which` succeeded python2 /Users/joshtoth/.pyenv/shims/python2
│ gyp ERR! configure error
│ gyp ERR! stack Error: Command failed: /Users/joshtoth/.pyenv/shims/python2 -c import sys; print "%s.%s.%s" % sys.ve…
│ gyp ERR! stack pyenv: python2: command not found
│ gyp ERR! stack
│ gyp ERR! stack The `python2' command exists in these Python versions:
│ gyp ERR! stack   2.7.18
│ gyp ERR! stack
│ gyp ERR! stack Note: See 'pyenv help global' for tips on allowing both
│ gyp ERR! stack       python2 and python3 to be found.
│ gyp ERR! stack
│ gyp ERR! stack     at ChildProcess.exithandler (node:child_process:421:12)
│ gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
│ gyp ERR! stack     at maybeClose (node:internal/child_process:1105:16)
│ gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
│ gyp ERR! System Darwin 22.6.0
│ gyp ERR! command "/Users/joshtoth/.nvm/versions/node/v20.5.0/bin/node" "/Users/joshtoth/dev/project_dir/node…
│ gyp ERR! cwd /Users/joshtoth/dev/project_dir/node_modules/.pnpm/node-sass@4.14.1/node_modules/node-sass
│ gyp ERR! node -v v20.5.0
│ gyp ERR! node-gyp -v v3.8.0
│ gyp ERR! not ok
│ Build failed with error code: 1
└─ Failed in 734ms at /Users/joshtoth/dev/project_dir/node_modules/.pnpm/node-sass@4.14.1/node_modules/node-sass
 ELIFECYCLE  Command failed with exit code 1.
/Users/joshtoth/dev/project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/task-runtime.ts:204
          throw new Error(
                ^
Error: Task "install" failed when executing "pnpm i --no-frozen-lockfile" (cwd: /Users/joshtoth/dev/project_dir)
    at new RunTask (/Users/joshtoth/dev/project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/task-runtime.ts:204:17)
    at TaskRuntime.runTask (/Users/joshtoth/dev/project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/task-runtime.ts:76:5)
    at NodePackage.installDependencies (/Users/joshtoth/dev/project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/javascript/node-package.ts:1502:13)
    at NodePackage.postSynthesize (/Users/joshtoth/dev/project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/javascript/node-package.ts:866:12)
    at MonorepoTsProject.synth (/Users/joshtoth/dev/project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/project.ts:618:14)
    at MonorepoTsProject.synth (/Users/joshtoth/dev/project_dir/node_modules/.pnpm/@aws+pdk@0.22.42_@aws-cdk+aws-cognito-identitypool-alpha@2.110.1-alpha.0_@pnpm+logger@5.0.0_@_xbq6lcvsguulglgpaubb2xhoey/node_modules/@aws/pdk/monorepo/projects/typescript/monorepo-ts.ts:545:11)
    at Object.<anonymous> (/Users/joshtoth/dev/project_dir/.projenrc.ts:29:9)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module.m._compile (/Users/joshtoth/dev/project_dir/node_modules/.pnpm/ts-node@10.9.1_@types+node@18.18.12_typescript@5.3.2/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
👾 Synthesis failed: Task "default" failed when executing "ts-node --project tsconfig.dev.json .projenrc.ts" (cwd: /Users/joshtoth/dev/project_dir)
/Users/joshtoth/.nvm/versions/node/v20.5.0/lib/node_modules/@aws/pdk/node_modules/execa/index.js:212
		throw error;
		^

Error: Command failed with exit code 1: pnpm projen
    at makeError (/Users/joshtoth/.nvm/versions/node/v20.5.0/lib/node_modules/@aws/pdk/node_modules/execa/lib/error.js:60:11)
    at module.exports.sync (/Users/joshtoth/.nvm/versions/node/v20.5.0/lib/node_modules/@aws/pdk/node_modules/execa/index.js:194:17)
    at module.exports.commandSync (/Users/joshtoth/.nvm/versions/node/v20.5.0/lib/node_modules/@aws/pdk/node_modules/execa/index.js:235:15)
    at Object.<anonymous> (/Users/joshtoth/.nvm/versions/node/v20.5.0/lib/node_modules/@aws/pdk/_scripts/exec-command.js:31:9)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47 {
  shortMessage: 'Command failed with exit code 1: pnpm projen',
  command: 'pnpm projen',
  escapedCommand: 'pnpm projen',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}
Error with python2
Progress: resolved 2395, reused 2366, downloaded 0, added 0, done
node_modules/.pnpm/fsevents@1.2.13/node_modules/fsevents: Running install script, done in 5.2s
node_modules/.pnpm/core-js@3.33.3/node_modules/core-js: Running postinstall script, done in 72ms
node_modules/.pnpm/core-js-pure@3.33.3/node_modules/core-js-pure: Running postinstall script, done in 73ms
node_modules/.pnpm/node-sass@4.14.1/node_modules/node-sass: Running install script, done in 709ms
node_modules/.pnpm/node-sass@4.14.1/node_modules/node-sass: Running postinstall script, failed in 1.1s
.../node_modules/node-sass postinstall$ node scripts/build.js
│ Building: /Users/joshtoth/.nvm/versions/node/v18.16.0/bin/node /Users/joshtoth/dev/my_project_dir/node_modules/.
│ gyp info it worked if it ends with ok
│ gyp verb cli [
│ gyp verb cli   '/Users/joshtoth/.nvm/versions/node/v18.16.0/bin/node',
│ gyp verb cli   '/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/bin/n
│ gyp verb cli   'rebuild',
│ gyp verb cli   '--verbose',
│ gyp verb cli   '--libsass_ext=',
│ gyp verb cli   '--libsass_cflags=',
│ gyp verb cli   '--libsass_ldflags=',
│ gyp verb cli   '--libsass_library='
│ gyp verb cli ]
│ gyp info using node-gyp@3.8.0
│ gyp info using node@18.16.0 | darwin | arm64
│ gyp verb command rebuild []
│ gyp verb command clean []
│ gyp verb clean removing "build" directory
│ gyp verb command configure []
│ gyp verb check python checking for Python executable "python2" in the PATH
│ gyp verb `which` succeeded python2 /Users/joshtoth/.pyenv/shims/python2
│ gyp verb check python version `/Users/joshtoth/.pyenv/shims/python2 -c "import sys; print "2.7.18
│ gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
│ gyp verb get node dir no --target version specified, falling back to host node version: 18.16.0
│ gyp verb command install [ '18.16.0' ]
│ gyp verb install input version string "18.16.0"
│ gyp verb install installing version: 18.16.0
│ gyp verb install --ensure was passed, so won't reinstall if already installed
│ gyp verb install version is already installed, need to check "installVersion"
│ gyp verb got "installVersion" 9
│ gyp verb needs "installVersion" 9
│ gyp verb install version is good
│ gyp verb get node dir target node version installed: 18.16.0
│ gyp verb build dir attempting to create "build" dir: /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-
│ gyp verb build dir "build" dir needed to be created? /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-
│ gyp verb build/config.gypi creating config file
│ gyp verb build/config.gypi writing out config file: /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-s
│ (node:62373) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be
│ (Use `node --trace-deprecation ...` to show where the warning was created)
│ gyp verb config.gypi checking for gypi file: /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-sass@4.1
│ gyp verb common.gypi checking for gypi file: /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-sass@4.1
│ gyp verb gyp gyp format was not specified; forcing "make"
│ gyp info spawn /Users/joshtoth/.pyenv/shims/python2
│ gyp info spawn args [
│ gyp info spawn args   '/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gy
│ gyp info spawn args   'binding.gyp',
│ gyp info spawn args   '-f',
│ gyp info spawn args   'make',
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-sass@4.14.1/node_modules/node-
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gy
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/Users/joshtoth/.node-gyp/18.16.0/include/node/common.gypi',
│ gyp info spawn args   '-Dlibrary=shared_library',
│ gyp info spawn args   '-Dvisibility=default',
│ gyp info spawn args   '-Dnode_root_dir=/Users/joshtoth/.node-gyp/18.16.0',
│ gyp info spawn args   '-Dnode_gyp_dir=/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_
│ gyp info spawn args   '-Dnode_lib_file=/Users/joshtoth/.node-gyp/18.16.0/<(target_arch)/node.lib',
│ gyp info spawn args   '-Dmodule_root_dir=/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-sass@4.14.1/
│ gyp info spawn args   '-Dnode_engine=v8',
│ gyp info spawn args   '--depth=.',
│ gyp info spawn args   '--no-parallel',
│ gyp info spawn args   '--generator-output',
│ gyp info spawn args   'build',
│ gyp info spawn args   '-Goutput_dir=.'
│ gyp info spawn args ]
│ Traceback (most recent call last):
│   File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/gyp_main.
│     sys.exit(gyp.script_main())
│   File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp
│     return main(sys.argv[1:])
│   File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp
│     return gyp_main(args)
│   File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp
│     options.duplicate_basename_check)
│   File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp
│     params['parallel'], params['root_targets'])
│   File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp
│     variables, includes, depth, check, True)
│   File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp
│     includes, True, check)
│   File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp
│     aux_data, includes, check)
│   File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp
│     LoadOneBuildFile(include, data, aux_data, None, False, check),
│   File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp
│     None)
│   File "/Users/joshtoth/.node-gyp/18.16.0/include/node/common.gypi", line 1
'uv_library%': 'static_library',
│                  ^
│ SyntaxError: invalid syntax
│ gyp ERR! configure error
│ gyp ERR! stack Error: `gyp` failed with exit code: 1
│ gyp ERR! stack     at ChildProcess.onCpExit (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.
│ gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
│ gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
│ gyp ERR! System Darwin 22.6.0
│ gyp ERR! command "/Users/joshtoth/.nvm/versions/node/v18.16.0/bin/node" "/Users/joshtoth/dev/my_project_dir/node
│ gyp ERR! cwd /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-sass@4.14.1/node_modules/node-sass
│ gyp ERR! node -v v18.16.0
│ gyp ERR! node-gyp -v v3.8.0
│ gyp ERR! not ok
│ Build failed with error code: 1
└─ Failed in 1.1s at /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-sass@4.14.1/node_modules/node-sass
 ELIFECYCLE  Command failed with exit code 1.
/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/task-runtime.ts:204
          throw new Error(
                ^
Error: Task "install" failed when executing "pnpm i --no-frozen-lockfile" (cwd: /Users/joshtoth/dev/my_project_dir)
    at new RunTask (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/task-runtime.ts:204:17)
    at TaskRuntime.runTask (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/task-runtime.ts:76:5)
    at NodePackage.installDependencies (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/javascript/node-package.ts:1502:13)
    at NodePackage.postSynthesize (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/javascript/node-package.ts:866:12)
    at MonorepoTsProject.synth (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/project.ts:618:14)
    at MonorepoTsProject.synth (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/@aws+pdk@0.22.42_@aws-cdk+aws-cognito-identitypool-alpha@2.110.1-alpha.0_@pnpm+logger@5.0.0_@_xbq6lcvsguulglgpaubb2xhoey/node_modules/@aws/pdk/monorepo/projects/typescript/monorepo-ts.ts:545:11)
    at Object.<anonymous> (/Users/joshtoth/dev/my_project_dir/.projenrc.ts:27:9)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module.m._compile (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/ts-node@10.9.1_@types+node@18.18.12_typescript@5.3.2/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
👾 Synthesis failed: Task "default" failed when executing "ts-node --project tsconfig.dev.json .projenrc.ts" (cwd: /Users/joshtoth/dev/my_project_dir)
/Users/joshtoth/.nvm/versions/node/v18.16.0/lib/node_modules/@aws/pdk/node_modules/execa/index.js:212
		throw error;
		^

Error: Command failed with exit code 1: pnpm projen
    at makeError (/Users/joshtoth/.nvm/versions/node/v18.16.0/lib/node_modules/@aws/pdk/node_modules/execa/lib/error.js:60:11)
    at module.exports.sync (/Users/joshtoth/.nvm/versions/node/v18.16.0/lib/node_modules/@aws/pdk/node_modules/execa/index.js:194:17)
    at module.exports.commandSync (/Users/joshtoth/.nvm/versions/node/v18.16.0/lib/node_modules/@aws/pdk/node_modules/execa/index.js:235:15)
    at Object.<anonymous> (/Users/joshtoth/.nvm/versions/node/v18.16.0/lib/node_modules/@aws/pdk/_scripts/exec-command.js:31:9)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  shortMessage: 'Command failed with exit code 1: pnpm projen',
  command: 'pnpm projen',
  escapedCommand: 'pnpm projen',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

Reproduction Steps

establish a new pdk project using the ts-monorepo command.

add this into the projenrc

import { javascript } from "projen";
import { monorepo } from "@aws/pdk";
import { CloudscapeReactTsWebsiteProject } from "@aws/pdk/cloudscape-react-ts-website";
import { InfrastructureTsProject } from "@aws/pdk/infrastructure";

const project = new monorepo.MonorepoTsProject({
  devDeps: ["@aws/pdk"],
  name: "mrproject",
  packageManager: javascript.NodePackageManager.PNPM,
  projenrcTs: true,
});

const anything = new CloudscapeReactTsWebsiteProject({
  parent: project,
  outdir: "packages/frontend",
  name: "frontend",
});

new InfrastructureTsProject({
  parent: project,
  outdir: "packages/infra",
  name: "infra",
  cloudscapeReactTsWebsite: anything,
});


project.synth();

and run pdk

In between tests of package name changes, ensure the directory frontend is deleted before using pdk again.

Possible Solution

No response

Additional Information/Context

pnpm store pruned, no change.
~/.pdk rm -rf'd , no change

PDK version used

0.22.10

What languages are you seeing this issue on?

Typescript

Environment details (OS name and version, etc.)

MacOS 13.5.1, node: 20.5.0 and 18.16.0

@JoshuaToth JoshuaToth added bug Something isn't working needs-triage labels Nov 22, 2023
@JoshuaToth JoshuaToth changed the title [BUG] Issue with CloudscapeReactTsWebsiteProject package name [BUG] Issue with CloudscapeReactTsWebsiteProject package name with infrastructureTS project Nov 22, 2023
@JoshuaToth JoshuaToth changed the title [BUG] Issue with CloudscapeReactTsWebsiteProject package name with infrastructureTS project [BUG] Issue with CloudscapeReactTsWebsiteProject package name with InfrastructureTsProject Nov 22, 2023
@agdimech
Copy link
Contributor

agdimech commented Nov 26, 2023

Hi Josh - you will need to be careful when naming your local workspace dependencies as frontend will actually resolve to: https://www.npmjs.com/package/frontend. The reason this occurs is that when the package.json is synthed, it will create a dependency like: frontend:"*" which will resolve to the actual frontend npm package given that is currently at a 2.x release. For most cases (where th published npm package is in the 1.x range), if your name conflicts with an npm package it will use your local dependency however in this case given frontend is in the 2.x range, that is preferred. We could potentially make a change to ensure local dependencies are resolved via workspace:*, however this is only supported in pnpm and bun so would still be problematic for yarn/npm.

The recommendation is to always scope your workspace packages to prevent conflicts with the public registry.

@JoshuaToth
Copy link
Contributor Author

oh damn, well yeah fair enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants