Skip to content

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

Description

@chmurray

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions