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

"ask deploy" on Mac gives "Cannot copy '<project_directory>/dist' to a subdirectory of itself, '<project_directory>/dist/.ask' error #510

Open
chmurray opened this issue Apr 24, 2024 · 0 comments

Comments

@chmurray
Copy link

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request 
[ ] Other... Please describe: 

Expected Behavior

The 'deploy' functionality should cause all of the contents of project '<project_directory>/dist' EXCEPT FOR '<project_directory>/dist/.ask' to be copied to <project_directory>/dist/.ask.

The 'deploy' functionality should not cause all of the contents of '<project_directory>/dist' to be copied to '<project_directory>/dist/.ask'. The '<project_directory>/dist/.ask' directory should be excluded from the copy.

Current Behavior

Running the 'deploy' command causes the following error in the "Build Skill Code" phase of the process: [Error]: Cannot copy '<project_directory>/dist' to a subdirectory of itself, '<project_directory>/dist/.ask'.

[Error]: Cannot copy '<project_directory>/dist' to a subdirectory of itself, '<project_directory>/dist/.ask'.

CLI Snapshot
If applicable, add screenshots to help explain your problem.

Steps to Reproduce (for bugs)

Try to deploy anything from a Mac.

Possible Solution

In order to get it working on my machine, I modified CodeBuilder._setupBuildFolder() (defined in lib/controllers/skill-code-controller/code-builder.js). I would have submitted a pull request with my changes, but they break two tests, and I wasn't quickly able to figure out how to resolve that. Here is what my CodeBuilder._setupBuildFolder() function looks like:

_setUpBuildFolder() {
fs.ensureDirSync(this.build.folder);
fs.emptyDirSync(this.build.folder);

// My Mac is rejecting the fs.copySync() call with the following error:
//    [Error]: Cannot copy '<path>/dist' to a subdirectory of itself, '<path>/dist/.ask'.
// It doesn't even try using the filter specified in the options argument.
//fs.copySync(path.resolve(this.src), this.build.folder, {filter: (src) => !src.includes(this.build.folder)});

// I am new to JavaScript.  
//    Please be kind with the feedback, but the following is working for me:

let srcFiles = fs.readdirSync(path.resolve(this.src));
for (const file of srcFiles) {

  let fullyQualifiedFileName = path.resolve(this.src, file);
  if (!fullyQualifiedFileName.includes(this.build.folder)) {

    if (fs.lstatSync(fullyQualifiedFileName).isDirectory()) {
      fs.copySync(fullyQualifiedFileName, this.build.folder);
    } else {
      fs.copyFileSync(fullyQualifiedFileName, this.build.folder + "/" + file);
    }

  }
}

}

Your Environment and Context

  • ask-cli version: 2.30.7
  • Operating System and version: MacOS Sonoma 14.4.1
  • Node.js version used for development: 21.7.2
  • NPM version used for development: 10.5.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant