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

issue with spawnCommandSync and (linux) mount during generator run #1507

Closed
deostroll opened this issue Mar 10, 2024 · 1 comment
Closed
Labels
needs triage Awaiting triage

Comments

@deostroll
Copy link

Here is a stub from my custom generator file:

    this._msg(`Mounting ${chalk.green('disks/config.img')} to ${chalk.green('.mnt')} ...`);
    this._runCmd('mount', ['disks/config.img', '.mnt']);

The _runCmd is defined as follows:

  _runCmd(...args) {
    this.log(args);
    let res = this.spawnCommandSync(...args);
    if(res.status === null) {
      throw res.error
    } else if(res.status !== 0) {
      throw new Error(`${arguments[0]} exited with non-zero code: ${res.status}`);
    }
  }

When this generator is run (as root), this command always fails. Below is the error output of failure:

mount: .mnt: failed to setup loop device for /home/osboxes/code/cloud-init-projects/proj1/disks/config.img

For an isolated test, I created a fresh nodejs project npm init -y install yeoman-generator (v3.2.0), and, prepared the below code:

const yg = require('yeoman-generator');
const execa = require('execa');
// console.log(yg.prototype.spawnCommandSync);
const printEmpty = () => console.log('');

let { spawnCommandSync } = yg.prototype;
spawnCommandSync('mkdir' , ['.mnt', 'disks']);
printEmpty();
spawnCommandSync('dd', ['if=/dev/zero', 'of=disks/config.img', 'bs=1', 'count=0', 'seek=2M']);
printEmpty();
spawnCommandSync('mkfs.vfat',['-n', 'cidata', 'disks/config.img']);
printEmpty();
spawnCommandSync('mount', ['disks/config.img', '.mnt']);

The above test does not error.

Additionally, the custom generator I was authoring earlier assumes there is a src folder in the directory (where the generator if finally run) with files to be copied over to the "mount" location.

What could be the reason for the failure of the mount command when run within the generator?

Code available here: https://gist.github.com/deostroll/3f7907b673ea7c544b385f2a399c45fa

@deostroll deostroll added the needs triage Awaiting triage label Mar 10, 2024
@mshima
Copy link
Member

mshima commented Mar 18, 2024

yeoman-generator v3.2.0 is more than 5 years old.
We only support latest version.

@mshima mshima closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Awaiting triage
Projects
None yet
Development

No branches or pull requests

2 participants